
Chest - Class to store procedures in a hash

; use Chest
; my $chest=new Chest
; sub hello
{ $val={ 'de' => 'hallo', 'en' => 'hello' }->{shift()}
; sub { my $pers=shift; ucfirst($val)." ".$pers } }
; $chest->insert("hello world",\&hello("de"))
; print $chest->take("hello world","Welt")

This is a simple interface to call subroutines by strings. So it is easy to have longer but readable function calls or totally cryptical ones.

newA simple Constructor for a hash based object.
insert ; $chest->insert("name",sub{my $a=$_[0];sub{$a}},"name")
Important is the second method argument. It's used to be a valid code reference with another code reference as return value. This code ref is then stored under the value from first argument. If an entry exists under this name, this method does nothing. Additional arguments will be used when the second argument is executed.
insert_alwaysSame as above but overwrites existing entries.
existsCheck if an an entry with a given name exists.
takeExecute a stored subroutine with the given arguments.


Getting feedback and correct all mistakes in code and documentation.

Sebastian Knapp

Copyright (C) 2006 by Sebastian Knapp
This library is free software; you can redistribute it and/or modify it under the same terms as perl itself.