Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Update:

I wanted to add some details of what I've already tried. First of all, the function that returns this array of hashes is not mine. It's part of the ARSPerl package. The actual function is called ars_GetEntry() which returns a hash of all the fields in a form. I looked through ARS.pm and it looks like this function is coded in C, not Perl, so it doesn't look like I'll be able to hack it. (Unless my boss is willing to pay for me to take a C class... :-) )

When calling the function, one of the arguments is the index of the particular record I want to retrieve. The keys to the hash are the field ID numbers from that form. This works fine for all the other fields I need to get - I have no problem retrieving and printing all the other information I need.

If one of the fields is a 'diary' field (Which I think is specific to Remedy), then that element of the hash is an array of hashes. Does that make sense? It took me a few times reading to understand it. IOW, quoting the documentation for this function:

ars_GetEntry(ctrl,schema,entry_id,...)

This function returns a hash (associative array) of field ids and values for a given schema and entry id. If you specify any field ids after the entry_id parameter, only the values for those fields will be returned, otherwise all field id value pairs are returned. All field values are converted into numeric or string values, except for the diary type. The diary field type is encoded as an array of hashes. Each hash has a timestamp, user and value field.

Here is one thing I have done that works, sort of:

@diary_entry = keys %{$diary_data[0]}; for $temp (@diary_entry) { print "$temp\n"; }

This returns:

$ ./send_referral.pl 0000079100 Diary ID: 536870914 timestamp value user

According to the docs, this is what I should see for the keys. Next, change the print statement, like so:

print "$temp: $diary_data[0]{$temp}\n";

This was interesting:

$ ./send_referral.pl 0000079100 Diary ID: 536870914 Use of uninitialized value at ./send_referral.pl line 201. timestamp: Argument "NWORLASTE800 LOGIN FAILED\nNWORLASTE801 LOGIN FAIL\n\nWA..." + isn't numeric in helem at ./send_referral.pl line 201. Bad index while coercing array into hash at ./send_referral.pl line 20 +1. $

The gibberish that looks like "NWORLASTE800 LOGIN FAILED\nNWORLASTE801 LOGIN FAIL\n\nWA..." looks like part of what I should see. This part of what should be in the data, under %hash{value}, and could run to thousands of characters. (The actual limit for this field is 500KB)

Finally, here are two things I have tried and the result:

@diary_entry = values %{$diary_data[0]}; print "@diary_entry\n";

and

# Another try: my %hash = %{$diary_data[0]}; @diary_entry = keys %hash; #@diary_entry = keys %{$diary_data[0]}; print "@diary_entry\n"; for $temp (@diary_entry) { print "$temp\n"; }

give me an error that says "Out of memory during ridiculously large request at ./send_referral.pl line 194." (Line 194 says "my %hash = %{$diary_data[0]")

So, to summarize, I have an array of hashes. I can get the keys to those hashes but I can't get any data out of them. Thank you Ovid, AgentM, and hdp for the suggestions. I'll be reading them carefully to make sure I understand them.

Chumley

In reply to More info: array of hashes 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 meditating upon the Monastery: (5)
As of 2024-04-23 11:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found