in reply to Re^3: How to call sub defined in a variable?
in thread How to call sub defined in a variable?
See perlmod for the gory details of how it works.use strict; use warnings; sub test { print "something"; } sub another_test { print "something else"; } sub third_test { print "another unimaginative statement"; } $\ = "\n"; my @ary = qw( test another_test third_test ); my $sub_i_want_to_call = $main::{$ary[rand(@ary)]}; $sub_i_want_to_call->();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: How to call sub defined in a variable?
by jh- (Scribe) on Jan 25, 2009 at 21:58 UTC |