c:\@Work\Perl>perl -wMstrict -le "my $r = '123'; ;; for my $s ('', qw(1 12 123 1234 2 23 234)) { my $left_same = 0 == index($r, $s); my $all_same = $r eq $s; printf qq{%-6s with more stuff could %smatch with '$r' \n}, qq{'$s'}, ($left_same and not $all_same) ? '' : 'NOT ' ; } " '' with more stuff could match with '123' '1' with more stuff could match with '123' '12' with more stuff could match with '123' '123' with more stuff could NOT match with '123' '1234' with more stuff could NOT match with '123' '2' with more stuff could NOT match with '123' '23' with more stuff could NOT match with '123' '234' with more stuff could NOT match with '123'