sub linkify { my $text = shift; # translate the square bracket URL links to real (HTML) links 1 while $text =~ s/\[((?:(?:(?:(?:(?:http|ftp|gopher|news):\/\/)|mailto:)|\/)[^\|]+?)|\/)\]/$1<\/a>/; 1 while $text =~ s/\[((?:(?:(?:(?:(?:http|ftp|gopher|news):\/\/)|mailto:)|\/)[^\|]+?)|\/)\|(.+?)\]/$2<\/a>/; # translate the square bracket select (com, net, org only) email links to # real (HTML), mailto: links 1 while $text =~ s/\[(.+?@.+?\.(com|net|org))\|(.+?)\]/$3<\/a>/; 1 while $text =~ s/\[(.+?@.+?\.(com|net|org))\]/$1<\/a>/; # Google, for instance. Others become easy by following this example. 1 while $text =~ s/\[(google):\/\/([^|]+)\]/$1<\/a>/; 1 while $text =~ s/\[(google):\/\/([^|]+)\|(.+?)\]/$2<\/a>/; return $text; }