Detecting if internet is connected in perl
<p>I have this perl script to extract the source code of a webpage: </p>

<pre><code>#!/usr/bin/perl
use LWP::UserAgent;
my $ou = new LWP::UserAgent;
my $url = "http://google.com";
my $source = $ou-&gt;get("$url")-&gt;decoded_content;
print "$source\n";
</code></pre>

<p>Now, I want to check the internet status if it is connected or not before extracting the source code .</p>