Thanks to all for the replies. I see now that I did not make my problem clear enough. My script is accessing a company-proprietary package that interfaces with the server. The "Read()" routine from the package returns a hash. Depending on the event being read, the hash will have a different set of key/value pairs, but each hash contains an ID key/value pair so that the calling code can process the data correctly:
my %event = SECRET_PACKAGE_NAME::WaitForEvent($timeout);
My script is initiating an action which causes the server to spit out data at a much higher rate than normal. Originally I was reading a single hash and processing it real-time. Running some external diagnostics showed that I was missing some key data, so I decided to run a tight loop to collect ALL the data. I tried the following which didn't work:
my @Events; while(1) { my %event = (); eval { %event = SECRET_PACKAGE_NAME::WaitForEvent($timeout); }; if($@) { # timeout occurred, serial burst complete last; } else { push (@Events, \%event); } }# end while ... while(@Events) { # Get the first event, NOT the last one my $EventRef = shift(@Events); } # $EventRef points to garbage
Does this clarify my issue? I need to preserve all the key/value pairs of the received data somehow so that I can post-process the information. Thanks again for the responses
In reply to Re^2: Creating an array of hash references
by Bobc
in thread Creating an array of hash references
by Bobc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |