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 include 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 } }