in reply to strict refs usage

for my $test ( qw( test1 test2 )) { next unless my $test_sub = main->can( $test ); print "Dear user, test $test is currently running.\n"; $test_sub->(); }

Replies are listed 'Best First'.
Re^2: strict refs usage
by QM (Parson) on Sep 22, 2005 at 18:20 UTC
    Isn't this just a sneaky^Wintelligent way to use symbolic references? ;)

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

      Certainly you're still looking up a symbol name in a symbol table, but this is what Perl does internally when you call a subroutine anyway. No, knowing the name of the subroutine at compile-time doesn't allow any real optimization here.

      At least this approach gives a bit more safety over calling the symbolic reference directly.