Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Trouble getting data out of a hash

by toolic (Bishop)
on Oct 26, 2007 at 13:03 UTC ( #647375=note: print w/replies, xml ) Need Help??

in reply to Trouble getting data out of a hash

Use of uninitialized value in concatenation (.) or string at line 56.
You could use Data::Dumper to help narrow down the cause of this warning. At the top of your code, add:
use diagnostics; use Data::Dumper;
Later on in your code, use:
print Dumper($value);
diagnostics might also provide more helpful information.

Replies are listed 'Best First'.
Re^2: Trouble getting data out of a hash
by wruehl (Acolyte) on Oct 26, 2007 at 13:42 UTC
    Using Data::Dumper gives me the following:

    value is HASH(0xe8a5b0)

    Pairname is: PD110

    $VAR1 = {};

    It looks like there might be a problem with the stored hash. Any suggestions?

      First of all, the returned hash is empty so it's no wonder that you the uninitialzed warning. I've never used Net::SNMP but from a quick glance at the docs I see:
      $result = $session->get_request( [-callback => sub {},] # non-bloc +king [-delay => $seconds,] # non-bloc +king [-contextengineid => $engine_id,] # v3 [-contextname => $name,] # v3 -varbindlist => \@oids, );
      so I think you're call of request is wrong and should read
      $result = $session->get_request( -varbindlist => [$OID] );

      holli, /regexed monk/
        Doing it that way got me an undefined data dump from result, and an error for uninitialized value when trying to print $result directly. Ithink there is something wrong with the hash reference being returned in $value, I'm just not sure how to fix it.

        Edit: I was right about the hash being incorrect, it seems I was grabbing the incorrect Object ID from the MIB. It needed as trailing 0 off of the the syscurrentDate object I was trying to take. Thanks for all your help in figuring this out.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2022-08-08 15:45 GMT
Find Nodes?
    Voting Booth?

    No recent polls found