use strict; use warnings qw( all ); my $looking = 1; while (<>) { if ($looking && /test/) { print "start\n"; $looking = 0; } }