in reply to Recognizing numbers and creating links

I also suggest just a 2 pass solution: Just grab all that seems nummeric. Once you do that, process the output with a function. In our case the function will allow only numbers of 3 or 4 characters, and perhaps a comma as separator. Then you can play adding more cases, like a trailing dot, or allow negative numbers, etc. Sure, It can be done in less lines, but this way you can easily document each line with its purpose.

$_="ent 1 12 to 1402, 222-2222, 1304, 555.555.5555 and 501, 777 7777 1 +2,4567 11.111"; sub GO{ return "LINK($1)$2" if $_[0]=~/^(\d{3,4})(,?)$/; # here more cases return "NO($_[0])"; }; s/([\.\-\,\d]+)/&GO($1)/gexi; print $_ . "\n";