Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Answer: How do I replace a URL with a clickable hyperlink?

by jhourcle (Prior)
on Apr 06, 2005 at 03:50 UTC ( [id://445162]=note: print w/replies, xml ) Need Help??


in reply to Re: Answer: How do I replace a URL with a clickable hyperlink?
in thread How do I replace a URL with a clickable hyperlink?

"ABC.com" is not a URL -- it's a domain.

Assuming you had first matched the domain (and had it in a variable named $domain) and you knew that all of the domains were using a host named 'www' for protocol 'http', you could use:

my $link = "<a href='http://www.$domain'>$domain</a>";

How you match domains is up to you... but I know that I get annoyed when my jabber client thinks that my discussions about perl scripts should be turned into links to websites in Poland.

Replies are listed 'Best First'.
Re^3: Answer: How do I replace a URL with a clickable hyperlink?
by Anonymous Monk on Apr 06, 2005 at 18:20 UTC
    Well, here's what I ended up using: $text =~ s!(^\s+\.com)!$1!gi; This works but the only problem is that sometimes I'm grabbing ABC.com out of a block of text, that also includes an image. In that case, the image code is messed up because the above code looks for white space, then something, then .com, which also matches the html for the image. How can I have the image left along, and the above code applied to ABC.com? Thanks.

      You've probably noticed that what you wrote isn't what was displayed. I'd suggest posting this as a node under 'Seekers of Perl Wisdon', and that you place the tags <code></code> around the code, so it doesn't get interpreted as HTML.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://445162]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-23 07:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found