in reply to Two arrays. One hash.
and then simply assign them to the hash:sub zip { $#_ += @_ % 2; # force even nr of elements @_[ map +( $_, $_ + @_ / 2 ), 0 .. $#_ / 2 ] }
This is less efficient, but unlike the hash slice solution it can easily be used in the middle of a long expression.my %hash = zip(@keys, @values);
Makeshifts last the longest.
|
|---|