You need to distinguish between errors that curl sees, and errors that your http server is returning. The latter are not errors for curl. You can however easily inspect the http status code by adding to your curl the option
-w '%'\n%{http_code}\n' This will append to stdout the HTTP header, which is 200 for OK. So your perl can do something like
my $curl_result = `curl -s -S -w '%'\n%{http_code}\n' ...`; 2>/dev/null`; my @lines = split(/\n/,$curl_result); my $httpcode = $lines[-1]; if($httpcode eq 200){ print "ok\n"; } else{ print "error\n"; }