seek LOG 0,0; #### while ( ) { my $LINE = $_; if ( $LINE =~ m/002389983/ ) { print "Looking for: 002389983\n Found it in file: $LINE\n"; last; } } seek LOG, 0, 0; while ( ) { if ( $LINE =~ m/29994339499/ ) { print "Looking for: 29994339499\n Found it in file: $LINE\n"; }else { print "Could not find the second string: 29994339499\n"; } }