in reply to executing subroutines via variable

Although it's tempting to use eval in a situation like this, I prefer (ab)using coderefs, either by employing a hash of anonymous subs (rather than subs proper)...

package atm; my %code = ( var1 => sub { print 1 }, var2 => sub { print 2 }, # ... varN => sub { print N }, ); package main; if ( exists $atm::code{$varN} ) { $atm::code{$varN}->( object_vars($var1) ); } else { # no matching sub }

... or testing for the existance of the sub you want to run with can, and executing the coderef it returns.

if ( my $sub = atm->can($varN) ) { $sub->( object_vars($varN) ); } else { # no matching sub }

    --k.