in reply to Getting information from an array of hashes
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:my %hash = @{ $diary_data[0] };
The following eliminates the error:perl -w -e "$a[0]=[1,2];%hash=$a[0]"
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:
Will force a "Can't coerce array into hash" error.my %hash = %{ $diary_data[0] };
|
|---|