in reply to Doing "it" only once
There's also a shortcut: the flip-flop operator:
this will not check for /foo/ once it's found.while (<>) { if (1 eq (/foo/ .. (1x0))) { do_something(); } }
Of course, this is not any better than
my $found; while (<>) { if (!$found && /foo/) { $found++; do_something() } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Doing "it" only once
by Roy Johnson (Monsignor) on Sep 21, 2005 at 19:28 UTC | |
by ambrus (Abbot) on Sep 21, 2005 at 19:33 UTC |