the_slycer has asked for the wisdom of the Perl Monks concerning the following question:
It simply saves me having to write out a whack of if statements. (if this event call this subroutine), as well as allows me to quickly add handlers for various events.my %dispatch = ( 'sub_one' => \&sub_one, 'sub_two' => \&sub_two ); $dispatch{'sub_one'}('arg'); $dispatch{'sub_two'}('arg'); sub sub_one { $a = shift; print "Got to sub one: $a\n"; } sub sub_two { $a = shift; print "got to sub two $a\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl 5.005_03 woes
by liz (Monsignor) on Aug 07, 2003 at 18:22 UTC | |
|
Re: perl 5.005_03 woes
by Limbic~Region (Chancellor) on Aug 07, 2003 at 18:27 UTC | |
by freddo411 (Chaplain) on Aug 07, 2003 at 22:54 UTC | |
by the_slycer (Chaplain) on Aug 07, 2003 at 19:35 UTC | |
by Limbic~Region (Chancellor) on Aug 07, 2003 at 19:43 UTC |