PDA

View Full Version : CGI/Perl Query



ashben
December 14th, 2000, 05:17
I'm no CGI/Perl programmer but need this small script in a hurry. The script should lookup for a given URL (like : http://www.hdjsh.com/dkjsjk.htm) and return true or false based upon its existence and validity. So, if the URL is found the script should return true else false. I feel its just a matter of a particular network function in Perl but don't know which one. Even a C/C++ or TCL script/component would do. I just need a hint, I'll take care of the rest.

If anyone can submit their tips on the script or refer some online reference for perl functions (primarily network).

((( Thanks )))

robot
December 14th, 2000, 16:41
Use the LWP::Simple modules "head" function to see if a remote file exists.
The example below will set $return to "found" or "not found" depending on the existence of the file.



use LWP::Simple qw(head);
$return = head($url) ? "found" : "not found";

ashben
December 14th, 2000, 22:20
Thanks a lot. Just another thing I missed out earlier .. now how to embedd this Perl code in a PHP script (.php), so that in PHP I can check the value of the $return variable.

I know its tricky, but any help would be great!


[Edited by ashben on 12-15-2000 at 01:24 AM]