Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Re: Getting information from an array of hashes

by hdp (Beadle)
on Apr 26, 2001 at 01:36 UTC ( #75627=note: print w/replies, xml ) Need Help??

in reply to Re: Getting information from an array of hashes
in thread Getting information from an array of hashes

"However, one of the examples in perldsc is almost identical to something I already tried, following an example in Programming Perl."

I'm not sure that's true. What it seems you're trying to do -- i.e. take an arrayref and turn it into a hash -- isn't really covered in perldsc. The reason I pointed you to it was because of my %hash = $diary_data[0] and the accompanying error about Reference found where even-sized list expected, not because of anything in the other suggestions people made or other things you'd tried; I'm sorry if there was confusion there.

What happens if you try %hash = %{$diary_data[0]->[0]}? (This is a bit of a shot in the dark based on some of your other posts.)

"What confuses me is the fact that I'm following examples straight out of Perl references and getting these errors. I'm starting to wonder if I've found a bug in"

You may be right, but it's probably just a nested data structure that you haven't quite understood yet. Data::Dumper will help a lot, if that's the case (print Dumper($diary_data[0])).


Replies are listed 'Best First'.
Re: Re: Re: Getting information from an array of hashes
by chumley (Sexton) on Apr 26, 2001 at 03:53 UTC

    It's not that I'm trying to turn an arrayref into a hash, I'm trying to take a function that is supposed to return an array of hashes and get the data out of the hashes. Sorry if I wasn't as clear as I could be. (perldsc calls this a "list of hashes", which I thought would be the same thing. Maybe not?)

    It may well be the same thing as a nested data structure, and it's quite likely that I don't understand it yet. Happens to me a lot - that's why I have a shelf full of O'Reilly books!

      The more I look at it, the more it looks like an array of an array of hashes; I'm drawing this conclusion from the output you list from print "@{$diary_data[0]}\n" (i.e., it looks like a hashref).

      Whatever it is, Data::Dumper should easily sort it out.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2023-10-04 07:42 GMT
Find Nodes?
    Voting Booth?

    No recent polls found