shotgunefx has asked for the wisdom of the Perl Monks concerning the following question:
while ( my ($val,$index) = findone { $_ > 1000 } @elements){ # Do something }
Because it keeps track of where and what it's called with, it will never match past the first match which means it will fail on the second block. (Unless there are multiple matches in @tokens. Then it will fail on the N+1 iteration.)my @tokens = (tokens here); while ($line =<>){ chomp($line); die "$line is not a valid token" unless findone { m/^$line/ } @tok +ens; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Determine if sub is called from control block.
by lordsuess (Scribe) on Feb 27, 2002 at 11:24 UTC | |
by strat (Canon) on Feb 27, 2002 at 12:45 UTC | |
by shotgunefx (Parson) on Mar 02, 2002 at 21:24 UTC | |
by shotgunefx (Parson) on Feb 27, 2002 at 11:35 UTC | |
|
Re: Determine if sub is called from control block.
by lordsuess (Scribe) on Feb 27, 2002 at 09:58 UTC | |
by shotgunefx (Parson) on Feb 27, 2002 at 10:06 UTC | |
|
Re: Determine if sub is called from control block.
by shotgunefx (Parson) on Feb 27, 2002 at 03:13 UTC |