The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Chest - Class to store procedures in a hash

SYNOPSIS

  ; 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")
  

DESCRIPTION

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.

USAGE

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.

SEE ALSO

Callback

TODO

Getting feedback and correct all mistakes in code and documentation.

AUTHOR

Sebastian Knapp

COPYRIGHT AND LICENSE

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.