in reply to Re: what difference between eval and do ?
in thread what difference between eval and do ?

grep { s/\d+/a/ } @dd;

This is another instance of a mystery of which I've only recently become aware: The (mis(mis))use of grep in place of the (mis)use of map in place of a for-loop. See this discussion. Just for the satisfaction of my own curiosity, if you or anyone can offer any insight into the rationale behind this strange map/grep usage, I'd be mighty obliged.


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^3: [OT]: what difference between eval and do ?
by dsheroh (Monsignor) on Apr 20, 2018 at 08:21 UTC
    This is another instance of a mystery of which I've only recently become aware: The (mis(mis))use of grep in place of the (mis)use of map in place of a for-loop.
    Definitely agreed that it's a strange (mis|ab)?use of grep, but the map variant seems pretty canonical to me - it transforms the elements of a list and stores the resulting new list. The only thing that strikes me as questionable about it is that it overwrites the original list with the new one.
Re^3: [OT]: what difference between eval and do ?
by jimpudar (Pilgrim) on Apr 20, 2018 at 01:13 UTC

    This is just a case of "When all you have is a hammer, everything looks like a nail". Drives me nutty too...

Re^3: [OT]: what difference between eval and do ?
by LanX (Saint) on Apr 20, 2018 at 01:25 UTC
      Update: indeed I was able to reproduce it.

      My JS add on to produce monastery html tags plays a role here because multiple clicks produce different messages.

      A nonce could solve this. ..

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Wikisyntax for the Monastery

      I think these duplicates are caused by multiple clicks on send button because of a delayed response.

      Not sure if I have to blame my tablet's browser, my wifi router, my dsl provider or the monastery.

      probably all of them.

      Trying to reproduce it. ...

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Wikisyntax for the Monastery