in reply to Does 'use locale' Change What Is Considered To Be 'alphabetical order'?

Yes.

>perl -le"use open ':std', ':encoding(cp850)'; use if $ARGV[0], 'local +e'; print sort 'a', chr(0xE1), 'b'" 0 abá >perl -le"use open ':std', ':encoding(cp850)'; use if $ARGV[0], 'local +e'; print sort 'a', chr(0xE1), 'b'" 1 aáb

(Replace cp850 with the proper encoding for your console.)

You have a few problems:

The solution is to use POSIX or Unicode properties.

>perl -le"my $s = chr(0xE1); print $s =~ /\p{Alpha}/ ?1:0" 1 >perl -le"my $s = chr(0xE1); print $s =~ /[\p{Alpha}]/ ?1:0" 1 >perl -le"my $s = chr(0xE1); utf8::upgrade($s); print $s =~ /[[:alpha: +]]/ ?1:0" 1

From the documentation, it seems to me the following should also work, but they don't:

>perl -le"use feature 'unicode_strings'; my $s = chr(0xE1); print $s = +~ /[[:alpha:]]/ ?1:0" 0 >perl -le"use 5.012; my $s = chr(0xE1); print $s =~ /[[:alpha:]]/ ?1:0 +" 0

Update: Fixed c&p mistake in char class.
Update: Inserted Problem #1.
Update: Oops, I seem to have forgotten to include the solution. Added.

Replies are listed 'Best First'.
Re^2: Does 'use locale' Change What Is Considered To Be 'alphabetical order'?
by Old_Gray_Bear (Bishop) on Aug 08, 2010 at 00:50 UTC
    Yup, local for locale is a Typo.

    Bingo! 'encoding' is the piece I was missing. Thank you, ikigami. Now I'm off to re-factor and test the read-extract-and-build-the-list routines. I'll be back for air by mid-night....

    ----
    I Go Back to Sleep, Now.

    OGB

      That just causes STDIN, STDOUT and STDERR to properly decode and encode characters. It's got nothing to do with the problem at hand. I added a solution to my post as you posted this reply.