in reply to Creating a hash from arrays
An option using map:
use strict; use warnings; use Data::Dumper; my @fname = ( "Bob", "John", "Ashley" ); my @lname = ( "Johnson", "Hill", "Sharp" ); my @state = ( "AK", "CA", "AL" ); my %hash = map { $fname[$_] . ' ' . $lname[$_] => $state[$_] } 0 .. $# +state; print Dumper \%hash;
Output:
$VAR1 = { 'Bob Johnson' => 'AK', 'Ashley Sharp' => 'AL', 'John Hill' => 'CA' };
Hope this helps!
|
|---|