in reply to Re^2: How to call sub defined in a variable?
in thread How to call sub defined in a variable?
Thanks for suggestions, but I'm afraid that initializing the array with references instead of string literals would require lots of work in the context I'd need it.
I actually stumbled upon this, but it relies on no strict 'refs', and I'm left wondering if there's a way to do something similiar with use strict?
my @ary = qw( test another_test third_test ); my $sub_i_want_to_call = $ary[rand(@ary)]; { no strict 'refs'; &{$sub_i_want_to_call}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to call sub defined in a variable?
by Arunbear (Prior) on Jan 25, 2009 at 21:44 UTC | |
by jh- (Scribe) on Jan 25, 2009 at 21:58 UTC | |
|
Re^4: How to call sub defined in a variable?
by ysth (Canon) on Jan 25, 2009 at 23:59 UTC |