Using URI::Find to detect Web URL's

Discussion in 'Perl Misc' started by \Dandy\ Randy, Sep 9, 2003.

  1. 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, Sep 9, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Harris
    Replies:
    0
    Views:
    6,368
    Simon Harris
    May 10, 2005
  2. Stanimir Stamenkov
    Replies:
    1
    Views:
    2,469
    Stanimir Stamenkov
    Aug 17, 2005
  3. Pavel
    Replies:
    2
    Views:
    1,641
    Peter Flynn
    Aug 4, 2004
  4. etheriau
    Replies:
    1
    Views:
    666
    Pavel
    Aug 23, 2004
  5. Joe Curry

    Invalid URI: The format of the URI could not be determined.

    Joe Curry, Oct 8, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    341
    Joe Curry
    Oct 8, 2003
Loading...

Share This Page