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

In reply to Re^4: Foreach for array pruning? (Updated) by spandox
in thread Foreach for array pruning? by spandox

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.