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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Data::Dumper showed me the way. What I had was not an "array of hashes". It was, as far as I can tell, an array containing one element, and that element was an array, containing the hashes.

I finally figured it out when I tried this on a hunch:

print "${${$diary_data[0]}[0]}{user}\n"; print "${${$diary_data[0]}[0]}{timestamp}\n"; print "${${$diary_data[0]}[0]}{value}\n";

which gave me some good output:

MAWEBB 988227105 NSA NOTIFY NETWORK MAINTENANCE 4/24/01 + 22:05 CST

From there, I was able to come up with:

$i=0; while (${${$diary_data[0]}[$i]}{user}) { print "User:\t\t${${$diary_data[0]}[$i]}{user}\n"; print "Timestamp:\t${${$diary_data[0]}[$i]}{timestamp}\n"; print "Information:\t${${$diary_data[0]}[$i]}{value}\n\n"; $i++; }

This gives me exactly the information I'm looking for. All that's left is munging it into a decent format for e-mail.

There are still some things I need to do with cleaning up this code, and I need to go back over exactly why this works the way it does, but I think I'm on the right track here. Thanks again Monks for the help today! :-)

Chumley

In reply to Got it, sort of (Re: Array of hashes problem) by chumley
in thread Getting information from an array of hashes by chumley

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2023-12-01 17:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?