develooper Front page | perl.perl5.porters | Postings from May 2012

Question about 'perlre' Wrt locale

Thread Next
Linda W
May 16, 2012 14:45
Question about 'perlre' Wrt locale
Message ID:
A change that popped up in 'bash', was it started using something
similar to DOS/Windows rules for character sorting (apparently the en_US
locale doesn't know the difference between upper and lower case for sorting,
and 'a'<'A'<'b'<'B'...

To protect against this, I add "export LC_COLLATE=C" to my bash profile.

When I was reading the perlre section about the modifiers /a /d /l and /u.

I wondered when I might be at risk for a locale specific interpretation of
ranges --- so I set my LC_COLLATE var back to it's distro-default
for my locale "en_US.UTF-8".

In bash, this gives the "fun" result:

echo out=$out
Z   #(upper case Z)

When I tried a locale specific replacement (used both, 'use locale and 
"/l" as well as each, alone) in perl of the same sort:

perl -wE 'use locale;
my $in="aAbBcCxXyYzZ";
my $out=($out=$in,($out=~ s/[a-z]//lg),$out);
print "out=$out\n";'

I get the traditional, "expected" result, not the new & modern 
that Bash is showing.

So my question is.. (be aware, I don't really like the new behavior, 
BUT... if
it IS supposed to be the locale specific behavior...)... how would one 
get a
similar butchery^h^h^h^h^h^h^h^hPOSIXly correct result?

I.e. should Perl's "use locale" have done the same?  If not, why not (other
than it's icky!)    I mean, if perl's going through the pain to put in
4 modifiers to change how substitutions and such are done, (affecting most
specifically, 'ranges', in this case), should one of them be creating 


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About