Charles

It does not print anything even though I know the time and ip_address
objects are populated as they print correctley.

I added the following ( and use Data::Dumper 'Dumper'; to the top of the
script )

foreach my $request (sort keys %response_hash) {
        #print "Response to request_id $request\n";
        foreach my $record(@{$response_hash{$request}}) {
        print Dumper @record;
                #print "Time : $record->{time}\n";
                foreach my $response ($record->{keys %response_values} )
                {
                        #print "Response to oid : $response =
$response_values{$response}\n";
                }
        }

What am I missing here ?

Thanks !

-----Original Message-----
From: Charles K. Clarkson [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 25, 2004 10:35 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: Normandin, Jason
Subject: RE: Hash Help Needed !


[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
: 
: I have run into a situation that I am unclear on.
: 
: I am making the following assignment during a loop:
: 
: push @{$response_hash{$request_id}},{time => "$time",ip_addr 
: => "$ip_address",oids => "%response_values"};

    I didn't test your code but "%response_values" is not the
same as \%response_values or %response_values. You have just
run into the problem with unnecessarily quoting variables.
(Read perlfaq4.)

    You might have wanted (White space is your friend.):

push @{ $response_hash{ $request_id } }, {
        time    => $time,
        ip_addr => $ip_address,
        oids    => \%response_values,
};



: 
: Where: response_values is a simple hash containing key,value 
: pairs and $time and $ip_address are simple scalar vars.
: 
: I can iterate through the %response_values hash after it is 
: created localy using simple foreach my $value (keys 
: %response_values ) syntax, but when I try to include that 
: iteration when iterating the main response hash, I am not 
: getting any values.
: 
: I am using the following syntax:

    Add this near the top of your script. It adds a function
named Dumper to your script.

use Data::Dumper 'Dumper';

: 
: foreach my $request (sort keys %response_hash) {
:       print "Response to request_id $request\n";
:       foreach my $record(@{$response_hash{$request}}) {

    Test what is in $record with the Dumper function:

    print Dumper @record;
    exit;

    Is the result what you thought was in there?


:       
:               print "Time : $record->{time}\n";
:               print "IP : $record->{ip_addr}\n";
:               foreach my $response ($record->{keys %response_values} )
:               {
:                       print "Response to oid : $response = 
: $response_values{$response}\n";
:               }
:       }
:               
: }

HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
the latest virus scan software available for the presence of computer
viruses.
**********************************************************************

Reply via email to