Try using map instead:
In reply to Re: from array to hash with grep by sonofason in thread from array to hash with grep by jeanluca