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.
new
A 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_always
Same as above but overwrites existing entries.
exists
Check if an an entry with a given name exists.
take
Execute a stored subroutine with the given arguments.
Callback
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.
To install Chest, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Chest
CPAN shell
perl -MCPAN -e shell install Chest
For more information on module installation, please visit the detailed CPAN module installation guide.