my $s = "abcxyQ"; if ($s =~ /abc(?!xyz)/) { print "Matches '$s'\n"; } else { print "Doesn't Match '$s'\n"; } my $t = "abcxyz"; if ($t =~ /abc(?!xyz)/) { print "Matches '$t'\n"; } else { print "Doesn't Match '$t'\n"; }