Frankly, that is more bizarre. You jumped from "grep works on lists and arrays" to "grep works on lists in the normal way and does something completely different to arrays"?

But if your worry was that someone rather magically thought that grep on an array removes things from the array, then why did you demonstrate a lack of optimization rather than demonstrating that grep doesn't modify the array?

In any case, I don't think your point was well understood (which doesn't surprise me). I think you would have been more helpful had you responded differently to the slightly redundant but not incorrect inclusion of "and arrays" which likely shows a leak of or bow to the common false dichotomy between "list" and "array" in Perl. Rather than elevate this false dichotomy to the point of "works on arrays" means "does something /different/ with arrays", you should have just noted that "grep works on lists. an array can be used as a list". That is, push back against the false dichotomy.

grep works on lists. So, of course, it also works on arrays (which are a type of list).

Bizarre consequences of optimizations of foreach seem particularly unenlightening to, more distracting from that point.

- tye        


In reply to Re^7: (Mis)Understanding "works" by tye
in thread (Mis)Understanding grep...eq $_ by ww

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.