Are you assuming that 'alpha' is also always the first line in the file?
Also, the posted flipflop doesn't behave the same as the OP
A simpler way to just use a flag and short circuit the regex work:
my $seen = 0; while (<$fh>) { if ( !$seen and m/^alpha$/) { $seen = 'yes indeed'; print "true\n"; }else{ print "false\n"; } }
Given a test file of:
The results I got are:foo bar alpha beta gamma delta
Original: false false true false false false Flipflop: Argument "" isn't numeric in numeric gt (>) at test.pl line 21, <$fh> +line 1. false Argument "" isn't numeric in numeric gt (>) at test.pl line 21, <$fh> +line 2. false false true true true Flag: false false true false false false
In reply to Re^3: A way to avoid repeated conditional loops
by SuicideJunkie
in thread A way to avoid repeated conditional loops
by Deus Ex
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |