The explanation by ++JohnGG pretty much nails it.

I might just add, by way of clarification of:

"This construct operates pretty much like grep to filter out any values that don't satisfy the conditions."

grep passes on its arguments unaltered if they satisfy the condition in BLOCK or EXPR:

$ perl -E 'say for grep length, qw{x y z}' x y z

map, on the other hand, passes on whatever the BLOCK or EXPR evaluates to for each argument:

$ perl -E 'say for map length, qw{x y z}' 1 1 1

You may already be aware of this; however, I thought it was worth pointing out: another reader may not be fully across this distinction.

— Ken


In reply to Re^3: How to get the index of smallest whole number in an array? by kcott
in thread How to get the index of smallest whole number in an array? by sohamsg90

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.