I cannot see a way to make it work using slices. This here utilizes slices but creates a different structure:
use strict; use warnings; use Data::Dumper; my $hash_ref; my @array1 = qw( some_unique_key1 some_unique_key2 some_unique_key3 ); my @array2 = qw( meta_data_1 metadata_2 metadat_3 ); my @array3 = qw( submitted_date1 submitted_date2 submitted_date3 ); @{$hash_ref->{'Metadata'}}{ @array1 } = @array2; @{$hash_ref->{'Submitted date'}}{ @array1 } = @array3; print Dumper $hash_ref;
creates
$VAR1 = { 'Metadata' => { 'some_unique_key3' => 'metadat_3', 'some_unique_key2' => 'metadata_2', 'some_unique_key1' => 'meta_data_1' }, 'Submitted date' => { 'some_unique_key3' => 'submitted_date3 +', 'some_unique_key2' => 'submitted_date2 +', 'some_unique_key1' => 'submitted_date1 +' } };
In reply to Re: Populating a hash-ref from multiple arrays with slice?
by hdb
in thread Populating a hash-ref from multiple arrays with slice?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |