in reply to references to subroutines
my %dispatch = ( add => \&add, multiple => \&multiply, ); my ($action, @args) = @ARGV; if ( exists $dispatch{ $action } ) { my $rv = $dispatch{ $action }->( @args ); print "Result of '$action' is '$rv'\n"; } else { warn "Invalid action '$action'\n"; }
Also, look in List::Util for better versions of your add and multiply routines.
|
|---|