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.

In reply to Re^3: detecting URLs and turning them into links by polettix
in thread detecting URLs and turning them into links by keiusui

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.