use URI; use URI::Find; use strict; use warnings; my $text = <<'__TEXT__'; Hi there, please read http://perlmonks.org/?node=How+to+RTFM. That's http://perlmonks.org/index.pl?node_id=78752. Students can activate their UMSIS userids on-line by filling out and submitting the form at https://umsis.miami.edu/sign-up. ...which can be obtained via the web at http://www.miami.edu/it-forms/ +. Holy snot http://batman.com, would you look at this!?!?! __TEXT__ find_uris($text, sub { my ($find_uri, $orig_uri) = @_; my $uri = URI->new( $orig_uri ); $uri = $uri->canonical->as_string; return '<a href="' . $uri . '">' . $uri . '</a>'; }); print $text; __END__ Hi there, please read <a href="http://perlmonks.org/?node=How+to+RTFM" +>http://perlmonks.org/?node=How+to+RTFM</a>. That's <a href="http://perlmonks.org/index.pl?node_id=78752">http://pe +rlmonks.org/index.pl?node_id=78752</a>. Students can activate their UMSIS userids on-line by filling out and submitting the form at <a href="https://umsis.miami.edu/sign-up">h +ttps://umsis.miami.edu/sign-up</a>. ...which can be obtained via the web at <a href="http://www.miami.edu/ +it-forms/">http://www.miami.edu/it-forms/</a>. Holy snot <a href="http://batman.com/">http://batman.com/</a>, would y +ou look at this!?!?!
Hi there, please read http://perlmonks.org/?node=How+to+RTFM. That's http://perlmonks.org/index.pl?node_id=78752. Students can activate their UMSIS userids on-line by filling out and submitting the form at https://umsis.miami.edu/sign-up. ...which can be obtained via the web at http://www.miami.edu/it-forms/. Holy snot http://batman.com/, would you look at this!?!?!
update: for emails, try Email::Find (didn't see that coming)
In reply to Re^3: replace url in text with html link
by PodMaster
in thread replace url in text with html link
by thealienz1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |