my @array = ( "received 480 response", "received 485 response", "received 486 response", "received 487 response" ); for (@array) { if ( $_ =~ /received 486 response/ ) { print "matched $_\n"; } else { print "did not match $_\n"; } } ________________________________________________ Output is: F:\>script.pl did not match received 480 response did not match received 485 response matched received 486 response did not match received 487 response