Hi I am scoping the %response_values hash at the top. I dont understand why it would need to be temporary as I am referancing that hash outside of the loop when I iterate through.
I changed the syntax to referance the oids rather then the hash name and I get the following error: Can't use string ("%response_values") as a HASH ref while "strict refs" in use at H:\nhsParseSnmpLog.pl line 72, <SNMP_L OG> chunk 78. Here is what I have: .. SNIP.. use strict; my (%request_hash,%response_hash); .. SNIP... elsif ( m/RESPONSE:/ ) { my ($time,$timeSecs,$request_id,$ip_address,%response_values,$oid,$oid_value); # Set these local to each record my @lines = split/\n/; foreach my $line (@lines) { next if $line =~ m/REQUEST:/; $timeSecs=$1 if $line =~ m/# Time (\d+)\.\d+ seconds/; $time=convertUtcToLocaltime($timeSecs); $request_id=$1 if $line =~ m/\[REQUEST_ID\] (\d+)/; $oid=$1 if $line =~ m/\[OBJECT_ID \] (.+)/; $oid_value =$1 if $line =~ m/[\[COUNTER \]|\[GAUGE \]|\[INT \]|\[TICKS \]] (.+)/; $response_values{$oid}=$oid_value; } push @{$response_hash{$request_id}},{time => "$time",oids => "%response_values"}; } .. SNIP .. foreach my $request (sort keys %response_hash) { #print "Response to request_id $request\n"; foreach my $record(@{$response_hash{$request}}) { #print "Time : $record->{time}\n"; foreach my $response (keys %{ $record->{'oids'} }) { #foreach my $response ($record->{keys %response_values} ) print "Response to oid : $response = $record->{'oids'}{$response}\n"; } } #print "============================\n"; } I am thoroughly confused at this point :( = Jason -----Original Message----- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Thursday, March 25, 2004 10:45 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; Normandin, Jason Subject: RE: Hash Help Needed ! > [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: [snip] > : > : print "Time : $record->{time}\n"; > : print "IP : $record->{ip_addr}\n"; > : foreach my $response ($record->{keys %response_values} ) In addition to what Charles already stated, once you have cleared up the quoting problem and gotten your hash to store properly, then you will need to access the hash reference of the key in the main hash using 'oids' . In other words, you need to index into $record using 'oids' to get the hash reference, then take the keys of that dereferenced hash. foreach my $response (keys %{ $record->{'oids'} }) { I suspect you have a scoping issue with %response_values otherwise strict would have complained, are you declaring your variables when first used or all at the top? %response_values should have been a temporary variable scoped only to your first loop which you didn't show. http://danconia.org ********************************************************************** 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. **********************************************************************