my $HTTPCode =`curl -s -w "%{http_code}" -o /dev/null https://$THIS_URL 2>&1`; #this is the line i used to retrieve the http_code if($HTTP Code == 404){ #Send email }