in reply to Re^3: Foreach for array pruning? (Updated)
in thread Foreach for array pruning?

Why the inner code block?

As mentioned before, and explained in the comments, this is a trivial example that is meant to mimic the behavior of a foreach with the "added feature" I discussed earlier

The concept is to come up with something that could work with fairly complex code. Perhaps it is going to start with a list of servers - do some checks and remove from the array all of the servers that respond in a certain way when queried. This may take more than the trivial one line of code. "I" may also want to "fall out" of the code at many different points. That is why I made a version that had the "last" command in it.

I did not mention in the code my "normal" procedure either

my @temp; foreach (@moo) {if (! ($_ % 2)){push @temp, $_;}} @moo=@temp;

Which might I add, for an array or 1,000,000 elements benchmarks at around half of the time of any of the examples of that have an inner block (the last example above without the inner block cheats becuase it cannot be changed for any reasonable increase in code complexity

**************

Why does the parser have trouble when it is in a grep?

my $i=1; {{{print "$i";}; if ($i++ < 5){redo;}}}

Runs without hessitation, it is just nested code blocks for goodness sakes......and why can I do a last or redo within the codeblock of a grep - Why do I need to nest a second block in there?

Just curious
--Spandox