Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Creating links in the URLs in a text paragraph

by Zaxo (Archbishop)
on Jun 25, 2007 at 04:19 UTC ( #623106=note: print w/replies, xml ) Need Help??

in reply to Creating links in the URLs in a text paragraph

You can use Regexp::Common::URI to detect the the urls in plain text and perform a substitution. Assuming the text is in $_, the following will wrap with anchor tags, with the host as text.

use CGI qw/:html/; use Regexp::Common qw/URI/; s/$RE{URI}{HTTP}/a( {href => $1}, $3)/eg;

Untested. The /e flag on the substitution executes the CGI::a() function to obtain the substitute. The /g flag makes the substitution for all recognised urls in the text.

After Compline,

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://623106]
[Perl300]: Hi all
[Perl300]: I have a quick question about the Meta CPAN
[Perl300]: On any modules pod page, what does the date on top left corner below authors name indicate?

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2017-12-11 17:59 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (310 votes). Check out past polls.