develooper Front page | perl.perl5.porters | Postings from July 2018

tr'''

Thread Next
From:
Karl Williamson
Date:
July 17, 2018 01:49
Subject:
tr'''
Message ID:
fe96d8b8-eb5c-6b44-816b-cf5f2247178b@khwilliamson.com
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"
B

$ blead -le "my \$foo = 'A'; \$foo =~ tr'A-Z'a-z'; print \$foo"
a

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 reading.

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.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About