in reply to from array to hash with grep
A quick rule of thumb which might help to decide if you want grep or map.
If you have a list and you want to filter that list so that you don't get back all of the items, then you probably want grep.
If you have a list and you want to transform each item in the list in some way then you probably want map.
Generally speaking, given a list with N items, grep returns a list with <= N items and map returns a list with N items[1]
[1] Yes, I know that map can actually return more than N items and even less than N items - but my explaination is true to a first approximation.
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|