Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Hash of Hashes, referencing, dereferencing and Net::SNMP

by matija (Priest)
on Oct 06, 2004 at 12:16 UTC ( [id://396958]=note: print w/replies, xml ) Need Help??


in reply to Hash of Hashes, referencing, dereferencing and Net::SNMP

Well, the problem is here:
$results_table->{$$group}}->{$$site_name} = { sysobjid => "unknown", snmp_status => "NOT OK +", };
Contrary to what might be convenient, you are assigning a whole new hash reference (and leaving the old hash orphaned and subject to garbage collection).

You will have to break the statement down into two parts:

results_table->{$$group}}->{$$site_name}->{sysobjid}="unknown; results_table->{$$group}}->{$$site_name}->{snmp_status}="NOT OK";

Replies are listed 'Best First'.
Re^2: Hash of Hashes, referencing, dereferencing and Net::SNMP
by Smylers (Pilgrim) on Oct 06, 2004 at 15:28 UTC
    You will have to break the statement down into two parts:
    results_table->{$$group}}->{$$site_name}->{sysobjid}="unknown; results_table->{$$group}}->{$$site_name}->{snmp_status}="NOT OK";

    If you want to put the convenience back then use a fake loop to avoid the repetition:

    for ($results_table->{$$group}{$$site_name}) { $_->{sysobjid} = 'unknown'; $_->{snmp_status} = 'NOT OK'; }
    Smylers
Re^2: Hash of Hashes, referencing, dereferencing and Net::SNMP
by revdiablo (Prior) on Oct 06, 2004 at 18:08 UTC
    You will have to break the statement down into two parts

    Another approach would be using a hash slice:

    my $site = results_table->{$$group}->{$$site_name}; # for convenience @{ $site }{("sysobjid", "snmp_status")} = ("unknown", "NOT OK");

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://396958]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-25 19:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found