my $command = shift; %commands = ( v => \&view, a => \&add, se => \&set, sh => \&show ); ($command) = grep $command =~ /$_/, keys %commands; &{$commands{$command}} if exists $commands{$command};