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