Hi Guys,

I am writing a Perl script that needs to initiate various http (or https) requests. Before doing so, I would like first to verify that a given string is indeed a valid URL address. I would like to do so (preferably) without using regexp.
Reason being, that URLs can be quite complex, and I'd prefer using a generic perl method (like a module). That way I am waaay more probable not to have missed any end-cases. Also, it would increase code-readability.

Thanks a bunch,
-FH

Recommended Answers

All 4 Replies

Is it correct that you don care that the URL exists, only that it is valid?

Hi FelineHazard:

The following modules from CPAN could be of help:
URI with URI::Escape.
Or Data::Validate::URI

However, I could only have one question; why validate if the URL doesn't exists?

Hope this helps. Enjoy.

Thanks that's exactly what I needed.
The URL might be online only sometimes. So first I check that the URL is valid, then that it is accisible, and depending on the result the answer would be logged and handled.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.