All you need to do is look for the links as you are doing, but make sure that the links are preceeded, and optionally followed, by whitespace.

This will never by true for something inside an A tag.

(Yes the real solution is to use a package from CPAN for recognising URLS, and parsing, but this is a hack on your hack).

You could use the following:

$myformtext =~ s!(\s)(http://\w.*?)(\s)!$1<a href="$2">$2</a>$3!gm;
Steve
---
steve.org.uk

In reply to Re: How to recognize url in text and convert to hyperlink, unless already in anchor by skx
in thread How to recognize url in text and convert to hyperlink, unless already in anchor by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":