use strict; use warnings; my $file = 'testpm.dat'; my $string1 = 'open'; my $string2 = 'close'; open F, $file; while () { # if only there was a way to find one string within another! } close F; if (I found string1 && I did not find string2) { print "Alarm!\n"; }