Using URI::Find to detect Web URL's

D

\Dandy\ Randy

A while back I added a post about URL detection. To date I have not been
able to figure it out. There seems to be very little docu. on this. This is
what I'm trying to do. I have an html web page with a single textarea form
named "content" The form action points to my detect.pl script.

#!/usr/bin/perl
use URI::Find;

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$form{$name} = $value;
}

$htmlcontent = $form{'content};
$htmlcontent=~ s/\n/<br>/g; #replaces breaklines with html <br>'s

<Missing URL detection code goes here>

open (FILE, ">data/content.txt") or &error("Unable to open");
flock FILE, 2;
print FILE $htmlcontent; #final scanned/replaced variable
close(FILE);

So basically what I'm looking to do is assign the form data to a variable,
then scan it for web AND email addressed, and repleace them with the needed
HTML tags ... <a href ... <mailto ... etc. ect. Then the changed data gets
saved to a text file, where I use SSI to include the data into my page.
Points to note would be the form data will almost always contain multipul
lines and perhaps multipul occurances of web addressed. Can someone please
help me fill in the missing code? TIA!!!!!

Randy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top