# Create a HASH which stores a mapping between function names # and the associated function references (\&). Add any other # functions to the quoted-word listing my %commands = map { $_ => \&$_ } qw[ set add mul ]; # ... while () { my ($command, $param) = split(" ", $_); # Check that the function exists before calling it, could have a # bad $command being passed. Perhaps add a warning in an # else block? if ($command{$command}}) { $register = $command{$command}->($register, $param); } }