while (my $line = ) { print $line; print "FOUND IT!\n" if $line =~ /foo/; }