use Text::Abbrev; use strict; print "Enter a command: "; chomp(my $action = ); # they could enter 'adm' or 'h' my %modes = abbrev(qw( hsbn admin ... )); # if $modes{$action} is defined, that means it is a # NON-AMBIGUOUS abbreviation of 'hsbn', 'admin', etc. if (defined(my $fullaction = $modes{$action})) { if ($fullaction eq 'hsbn') { ... } elsif ($fullaction eq 'admin') { ... } ... } else { print "$action was ambiguous.\n"; }