in reply to How to call sub defined in a variable?
my @subs = (\&test, \&another_test, \&third_test); my $sub_i_want_to_call = $subs[rand(@subs)]; $sub_i_want_to_call->();
See perlreftut for more informations.
Update: fixed copy&paste error in the code, thanks to ww++ for noticing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to call sub defined in a variable?
by Arunbear (Prior) on Jan 25, 2009 at 21:29 UTC | |
by jh- (Scribe) on Jan 25, 2009 at 21:41 UTC | |
by Arunbear (Prior) on Jan 25, 2009 at 21:44 UTC | |
by jh- (Scribe) on Jan 25, 2009 at 21:58 UTC | |
by ysth (Canon) on Jan 25, 2009 at 23:59 UTC |