use strict; use warnings; my @strings = ( '/lawyers/stuffLDSstuff/~Firms.html', '/lawyers/stuffnotstuff/~Firms.html' ); foreach my $string ( @strings ) { print $string; if( $string =~ m#/lawyers/(?!.*LDS).*~Firms\.html# ) { print " matches.\n"; } else { print " doesn't match.\n"; } }