develooper Front page | perl.beginners | Postings from April 2003

Re: multiple sorts

Thread Previous
From:
John W. Krahn
Date:
April 30, 2003 15:28
Subject:
Re: multiple sorts
Message ID:
3EB04E18.D74F4E11@acm.org
Kevin Pfeiffer wrote:
> 
> In article <3EAFA878.DE6AC17F@acm.org>, John W. Krahn wrote:
> 
> > You have to use the locale pragma for locales to work.
> >
> > # set the locale to whatever
> >
> > [some code that doesn't need locale]
> >
> > use locale;  # turn locale usage ON
> >
> > [some code that uses the locale]
> >
> > no locale;  # turn locale usage OFF
> 
> I was (but forgot to include it here). Here is my test script which I just
> looked at again (and which I still can't get to DWIM):

Fun, isn't it.  :-)

> #!/usr/bin/perl -w
> use strict;
> use locale;
> 
> # Import locale-handling tool set from POSIX module.
> use POSIX qw(locale_h);
> #
> # query and save the old locale
> my $old_locale = setlocale( LC_CTYPE, 'en_US.ISO8859-1' );

LC_CTYPE isn't going to affect sorting (as you have found out.)  You
need to use LC_COLLATE for sorting or LC_ALL for all locale settings.


John
-- 
use Perl;
program
fulfillment

Thread Previous


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