Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

(Ovid - need to dereference) Re: Getting information from an array of hashes

by Ovid (Cardinal)
on Apr 25, 2001 at 20:40 UTC ( [id://75530]=note: print w/replies, xml ) Need Help??


in reply to Getting information from an array of hashes

I believe what you want is:
my %hash = @{ $diary_data[0] };
The "Reference found where even-sized list expected" stems from you trying to assign a scalar reference to a hash, but a hash expects a list with an even number of elements. You can reproduce that error from the command line:
perl -w -e "$a[0]=[1,2];%hash=$a[0]"
The following eliminates the error:
perl -w -e "$a[0]=[1];%hash=@{$a[0]}"

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Update: Fixed error in original reply. I had %{ $diary_data[0] } instead of @{ $diary_data[0] }.

Update 2: Just saw AgentM's update. He was actually right. This code:

my %hash = %{ $diary_data[0] };
Will force a "Can't coerce array into hash" error.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-19 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found