Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Populating a hash-ref from multiple arrays with slice?

by jeffa (Bishop)
on Apr 16, 2015 at 17:41 UTC ( [id://1123644]=note: print w/replies, xml ) Need Help??


in reply to Populating a hash-ref from multiple arrays with slice?

The problem is that you have to store multiple values into an anonymous array ref, and hash slices implicitly loop on lists, not a scalar that points to an anonymous array ref. How about the old fashioned way instead?

use strict; use warnings; use Data::Dumper; my %hash; 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"; for (0 .. $#array1) { $hash{ $array1[$_] } = [ $array2[$_], $array3[$_] ]; } print Dumper \%hash;

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1123644]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-18 17:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found