do { $content = make_get_request($url_reports); $tries--; } while ($content == "[]" && $tries > 0); print $content."\n"; print "check:".($content == "[]")."\n"; if ("$content" == "[]") { print "Failed to report.\n"; } else { print "Successfully reported.\n"; } sub make_get_request { # Builds cmd for checking in API return `$cmd`; } #### [{"_id":"123125125","files":6,"user":"abcasda","timestamp":1571685134,"runtime":3,"run_name":"checking"}] check:1 Failed to report. Successfully reported.