This is fairly straight-forward to fix - Try changing your validURL subroutine to read thus:
sub validURL {
my ($self, $url) = @_;
my $req = new HTTP::Request HEAD => $url;
my $res = $self->request($req);
my $content = $res->content;
return 0 unless $res->is_success;
return 0 if $content =~ /the page you have requested cannot be fou
+nd/i;
return 1;
}
Note that I have changed the request method from POST to HEAD - The POST method will not be allowed for most URLs (thereby generating your false-negative results) and while this could be changed to a GET request, the HEAD request method will be more successful for all "valid" URLs, irrelevant of the preferred request method.
perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|