Good that I escaped early, then!
I only partially agree, and I was a bit too lazy to point all this out in the beginning. The matter of spotting a URI inside a text is quite difficult. But I think that the fact is that many of those characters are valid for a URI, so it's probably an error putting them right after a URI without separating them from the URI itself with a space.
In particular, according to the standard the full stop is an unreserved character, and the comma and the semicolon are sub-delimiters that play no role in the HTTP scheme. This is why http://www.polettix.it/, and http://www.polettix.it/ciao, are perfectly valid HTTP URIs even with the comma. There is no really correct solution for this: if you keep them you'll annoy your audience most of the time, if you decide to keep them out you're ignoring that they are perfectly valid characters in a URI. I would simply stick to the simplest solution, i.e. the global substitution in this case.
I also didn't elaborate about why the OP was having difficulties with h(er|is) approach, which was basically due to the fact that splitting on spaces... leaves the newlines. And there are other spacing chars to consider, too, so something along these lines: my @parts = split /(\s+)/, $message; # parents preserve spaces
# operate on @parts as in the OP
my $filtered = join '', @parts;
would probably be better. But, again, the problem is there for all those nasty punctuation marks, so there is really no advantage over the global substitution (apart from clarifying things for the OP).
Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
Don't fool yourself.
| [reply] [d/l] |