in reply to Fixing Experimental Keys error caused other errors to occur

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.

Replies are listed 'Best First'.
Re^2: Fixing Experimental Keys error caused other errors to occur
by MysticElaine (Novice) on May 06, 2021 at 18:29 UTC
    This helped me to figure out there had to be something wrong in our dev environment. It script died at the first part but we checked that Gearman was up and running fine. I moved the script to non-dev but still ran it on QA db - the script then passed the first debug but died at the JSON debug. I then ran the script on a non-QA db ticket and it worked. So thanks for the debug help!