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() } }
In reply to Re: Doing "it" only once
by ambrus
in thread Doing "it" only once
by Limbic~Region
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |