I am using LWP to parse a website from a url collected via a form. I want to know if it's possible to check to see if the URL exists. I get weird situtations where sometimes if they use the space bar it will run as if they input a url, if they input http:// first (since I add it myself), it can't find the url. And if they add something like "324242342543" or "test.com" it tries to find it from my server and prints out "myserver.com". So I'm confused, I know
defined doesn't check for url validity, is there something else I can try? And if I have to go with modules, I really need it to be one that's commonly installed rather than one I have to download.
I don't want to see if the url looks good, since I am parsing the webpage they provide for text, I need to say "Okay, the page is found..let's work" or "Nope, page can't be found so let's terminate".
my $geturl = "http://$url";
my $content = get("$geturl");
unless (defined $content)
{
print "<center>URL not found!</center><br><br>";
exit;
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.