But if the OP wants it as slice, this is the code:
@array1 = qw(some_unique_key1 some_unique_key2 some_unique_key3); @array2 = qw(meta_data_1 metadata_2 metadat_3); @array3 = qw(submitted_date1 submitted_date2 submitted_date3); my $hashref; # @hash{@keys} = @values; @$hashref{@array1} = map { {'Metadata' =>$array2[$_], 'Submitted Date' +=>$array3[$_]} } 0..$#array1; use Data::Dumper; die Dumper $hashref;
It would then give this as output:
$VAR1 = { 'some_unique_key3' => { 'Submitted Date' => 'submitted_date3', 'Metadata' => 'metadat_3' }, 'some_unique_key2' => { 'Submitted Date' => 'submitted_date2', 'Metadata' => 'metadata_2' }, 'some_unique_key1' => { 'Submitted Date' => 'submitted_date1', 'Metadata' => 'meta_data_1' } };
In reply to Re^2: Populating a hash-ref from multiple arrays with slice?
by FreeBeerReekingMonk
in thread Populating a hash-ref from multiple arrays with slice?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |