{command1} {file [file2 ...]} {dest_path} {command2} {file_name} {dest [dest2 ...]} {command3} {url} {file} {word [word2 ...]} {email@address} #### # assume that $_ is input line with command word removed, # and that @tab_completions is sorted by string length: my $i = 0; while ( $i < @tab_completions ) { last if ( index( $_, $tab_completions[$i] ) == 0 ); $i++; } if ( $i < @tab_completions ) { # $i is the element that matched, so pull that string # off the command line, and proceed with handling other # args, if any } else { # user entered a typo, perhaps? }