http://www.perlmonks.org?node_id=1020335


in reply to Re^10: Is there any difference between prototype % and @ ?
in thread Is there any difference between prototype % and @ ?

it's a common idiom to use map to create listified hashes map { $_ => 0 } LIST
  1. That's not a chain.
  2. You're starting with a list and ending with a hash.

    The point being, map is being used to manipulate a list to produce another list which only becomes a hash on assignment.

    hgrep (my version at least) is starting with an existing hash; which it manipulates as pairs; and produces a list which might get assigned to construct another hash; or perhaps joined into a string; or chained into map or sort; or any other construct that takes a list.

    Your version destroys the 'hashiness' of the hash by converting it to a list before your function gets its hands on it. Which means you have to accumulate the list into an array internally in order to reconstruct the pairs; before you can manipulate it in a 'hashy' kind of way.

    So you've deconstructed the hash to a list; constructed an array from it; then destructively decomposed that array (with splice) to obtain the pairs for passing to the callback.

    My version skips all that and obtains the pairs directly from the hash using each.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.