Looking at the docs for Gearman::Client that do_task method returns an undef on failure or a scalar ref to the result value on success. You need to check for that failure (and/or other possible failures; handwavy sample follows but you could go even further checking if decode_json throws an error) before you try and dereference it to decode whatever JSON into something you can treat as a hashref.
my $result = $client->do_task( ... ); if( not defined $result ) { ## Presumably there may be some other information about the failure +but I don't ## see offhand how to retrieve that; but that's a good thing to incl +ude in your ## error message here die "isok not ok for ip '$ip'!\n"; } my $json_result = decode_json( ${ $result } ); if( not ref $json_result or not ref $json_result->{ $ip } or ref $json +_result->{$ip} ne q{HASH} ) { die "Did not get back the hashref expected for '$ip'\n"; } my @result = keys %{ $json_result->{ $ip } }
Edit: Tweaked variable name last line. Derp. And expanded on description of method's return value. MOAR EDITS
The cake is a lie.
The cake is a lie.
The cake is a lie.
In reply to Re: Fixing Experimental Keys error caused other errors to occur
by Fletch
in thread Fixing Experimental Keys error caused other errors to occur
by MysticElaine
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |