jh- has asked for the wisdom of the Perl Monks concerning the following question:
O Mighty Monks,
Sorry for the probably confusing title, I just don't know how to suppress the question to a short(er) form.. ;)
Basically I need to call a subroutine when I have its name on a variable. Like this:
use strict; use warnings; sub test { print "something"; } sub another_test { print "something else"; } sub third_test { print "another unimaginative statement"; } my @ary = qw( test another_test third_test ); my $sub_i_want_to_call = $ary[rand(@ary)];
And now I'd want to call the subroutine which name is on $sub_i_want_to_call. How would I do this?
Thanks in advance,
Joeli
|
---|