%hash = map { join( q{ }, $fname[$_], $lname[$_] ) => $state[$_] } 0
+ .. $#fname;
Update: Though it's not necessarily better in this case, it is sometimes convenient to place the map inside the key brackets of a hash slice:
@hash{ map{ join q{ }, $fname[$_], $lname[$_] } 0 .. $#fname }
+= @state;
List::MoreUtils might be fun... let's see.....:
use List::MoreUtils qw( zip pairwise );
# ...
%hash = zip @{[ pairwise { join q( ), $a, $b } @fname, @lname ]},
+ @state;
Maybe that's just ridiculous. ;)
I should mention that if you didn't have the requirement of joining @fname and @lname stringwise, and instead were dealing with just a single list of keys, and a single list of values, the hash slice technique would be an ideal solution:
@hash{@names} = @states;
It doesn't get more succinct than that.
|