in reply to flag function

Using a variable to keep state is a perfectly acceptable solution. But since TIMTOWTDI, here's one way to do the same using the flip-flop operator. I've also made several stylistic suggestions, since that's what I find "uncomfortable" about your original code ;-)

use warnings; use strict; my $file = $ARGV[0]; open my $fh, '<', $file or die "$file: $!"; while (<$fh>) { if ( (/test/..0) eq '1' ) { print "start\n"; } } close $fh;