in reply to Calling a subroutine from a scalar

There's plenty of ways. The best is this:
use strict; sub func1 { print "Here\n"; } my $var = \&func1; $var->();
You take a reference to the function and store it in a scalar, then dereference the scalar.

If you want to use the name of the function, the best thing to do is a dispatch table.

my %dispatch = ( func1 => \&func1, func2 => \&func2, ); my $var = 'func1'; $dispatch{$var}->();

This way, you know which function names will be used and how they will be used.


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?