in reply to Re^3: How to call sub defined in a variable?
in thread How to call sub defined in a variable?

yes, use the names as lookups into the symbol table, e.g.
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->();
See perlmod for the gory details of how it works.

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

    Thanks, this is exactly what I was looking for. =)

    The OO version looks interesting too though, and I might end up using it instead.

    Thanks to all of you! :)