Charles

I was able to get the data dumper to work.

According to the output, the oids referance is referancing the hash for
response_values:

$VAR1 = {
          'oids' => '%response_values',
          'time' => '03/25/2004 03:16:39'
        };
$VAR1 = {
          'oids' => '%response_values',
          'time' => '03/25/2004 03:16:39'
        };
$VAR1 = {
          'oids' => '%response_values',
          'time' => '03/25/2004 03:16:39'
        };
$VAR1 = {
          'oids' => '%response_values',
          'time' => '03/25/2004 03:16:39'
        };

My guess is as that hash is local, that hash does not really exist.

Should it be showing the actual data rather then the hash referance ?

Ex.
$VAR1 = {
          'oids' => 'dat1=>value etc..',
          'time' => '03/25/2004 03:16:39'
        };

If so, what is wrong with my assignment statement ?

push @{$response_hash{$request_id}},{time => "$time",oids =>
"%response_values"};

How can I get the oids=> to populate the oids object with the vals ?

Thanks
Jason

-----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