Ask a Question related to PERL Miscellaneous, Design and Development.
-
\Dandy\ Randy #1
Using URI::Find to detect Web URL's
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
\Dandy\ Randy Guest
-
URL's in RSS Readers
I have a movie that pulls sports headlines from the BBC Sports xml feed. I can display the data ok, however, when i click on the stories, i'm not... -
opening external url's
Hey group, just wondering, is there a way to include a link in say, a label or something, and have it as a live link, so when someone clicks on it,... -
How do I use url's
:confused; I am trying to populate a form to be udated using a url. But I don't understand how to get it to pass take a look. I don't know how to... -
Tabs Nav Bar Setting Url's ?
Hi, I think I understand this but I just need someone to confirm it for me. When I set the URL in fireworks MX am I supposed to match the url to... -
Hiding URL's...
I read this article, and thought it was perfect for me... Just the same prob I'm having... http://forums.devshed.com/archive/5/2002/06/2/37330 ... -
John Bokma #2
Re: Using URI::Find to detect Web URL's
"Dandy" Randy wrote:
Amazing, this could be done with 2 lines using CGI.pm. Don't write your> 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};
own decoding stuff.
No need for that & IIRC> $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");
use Fnctl; to make is more readable (named constants instead of 2)> flock FILE, 2;
Also, I guess you should rewind since someone could have added between
the open and flock IIRC.
Finally, flock can fail...
You should test if close succeeds. Even print for that matter.> print FILE $htmlcontent; #final scanned/replaced variable
> close(FILE);
I recommend CGI.pm for this> So basically what I'm looking to do is assign the form data to a variable,
Sounds dangerous to me.> 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.
--
Kind regards, feel free to mail: mail(at)johnbokma.com (or reply)
virtual home: [url]http://johnbokma.com/[/url] ICQ: 218175426
John web site hints: [url]http://johnbokma.com/websitedesign/[/url]
John Bokma Guest
-
John Bokma #3
Re: Using URI::Find to detect Web URL's
Eric Schwartz wrote:
Cool to see others doing this as well. I consider using $query rather> my $cgi = CGI->new;
foolish in most cases :-). Using $cgi promotes self documenting code
--
Kind regards, feel free to mail: mail(at)johnbokma.com (or reply)
virtual home: [url]http://johnbokma.com/[/url] ICQ: 218175426
John web site hints: [url]http://johnbokma.com/websitedesign/[/url]
John Bokma Guest



Reply With Quote

