Front page | perl.perl5.porters |
Postings from July 2018
From: Dave Mitchell
July 17, 2018 08:19
Message ID: 20180717081906.GU2750@iabyn.com
On Mon, Jul 16, 2018 at 07:49:31PM -0600, Karl Williamson wrote:
> We do not fully support tr with single quotes. What does work is if all the
> characters in it are ASCII and each is listed without using ranges. If
> you do use a range, instead the dash is taken literally, so
> $ blead -le "my \$foo = 'B'; \$foo =~ tr'A-Z'a-z'; print \$foo"
> $ blead -le "my \$foo = 'A'; \$foo =~ tr'A-Z'a-z'; print \$foo"
> It would be some work to fix it to work properly in general, and I'm
> wondering if it is worth it, given that no one has ever complained, though I
> filed https://rt.perl.org/Ticket/Display.html?id=130679 based on code
> Instead of fixing it, an easier option would be to detect any uses where it
> doesn't work as expected and to raise a warning, probably a deprecation one
> so that we can at some later point die on such uses.
> Easier still is to document that a dash is taken literally.
It's already documented in perlop:
=head2 Gory details of parsing quoted constructs
=item C<''>, C<q//>, C<tr'''>, C<y'''>, the replacement of C<s'''>
The only interpolation is removal of C<\> from pairs of C<\\>.
Therefore C<"-"> in C<tr'''> and C<y'''> is treated literally
as a hyphen and no character range is available.
Little fly, thy summer's play my thoughtless hand
has terminated with extreme prejudice.
(with apologies to William Blake)
by Karl Williamson
by Dave Mitchell