How can I set $PageData to a error message like “$PageData=Page not found” if $URL is non extant or not responding? I cant seem to get it to work.
use LWP::UserAgent;
use HTTP::Request;
my $URL = "http://www.MyDomain.com/;
my $Request = HTTP::Request->new("GET", $URL);
my $UserAgent = LWP::UserAgent->new(timeout => 5);
my $Result = $UserAgent->request($Request);
return unless $Result->is_success;
$PageData = $Result->content;
print $PageData;
Try use library HTTP::Status with the following code: