Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: perllocale weirdness, bug, or...?

by Krambambuli (Deacon)
on Oct 20, 2010 at 14:14 UTC ( #866335=note: print w/ replies, xml ) Need Help??


in reply to Re: perllocale weirdness, bug, or...?
in thread perllocale weirdness, bug, or...?

I've checked with perllocale, but I just can't find any sense:

how is it possible to have a > b _and_ in the same time a@yahoo.com < b@yahoo.com...?


Krambambuli
---


Comment on Re^2: perllocale weirdness, bug, or...?
Re^3: perllocale weirdness, bug, or...?
by Corion (Pope) on Oct 20, 2010 at 14:21 UTC

    Oh - I hadn't seen that contradiction that runs counter to the intuition that "strings comparing larger" should compare starting from the left. I'm not sure what locale you actually run under. Maybe somebody who has actual working experience with locales can tell from $ENV{LC_ALL} or $ENV{LC_COLLATE} or $ENV{LANG} (see perllocale) what the active locale for your system is and how it affects sorting.

    I would still avoid locales, exactly because they introduce hard to track down behaviour.

      The problem is that I want to _reproduce_ under Perl the same order relation that the system level sort uses, as I want to process under Perl a file sorted outside Perl with sort and I rely on the strict ordering in the file to be conform with what Perl uses.

      Krambambuli
      ---

        The problem is that I want to _reproduce_ under Perl the same order relation that the system level sort uses

        What problem? You should have checked what order the system's sort uses.

        $ cat >data aaa2000@yahoo.com aaa_2000@yahoo.com aaa2000 aaa_2000 $ export LC_COLLATE=en_US.UTF-8 $ sort data aaa2000 aaa_2000 aaa_2000@yahoo.com aaa2000@yahoo.com $ perl -le'use locale; chomp(@a=<>); print for sort @a;' data aaa2000 aaa_2000 aaa_2000@yahoo.com aaa2000@yahoo.com $ export LC_COLLATE=C $ sort data aaa2000 aaa2000@yahoo.com aaa_2000 aaa_2000@yahoo.com $ perl -le'use locale; chomp(@a=<>); print for sort @a;' data aaa2000 aaa2000@yahoo.com aaa_2000 aaa_2000@yahoo.com

        Whether the order makes sense or not, it's doing exactly what you want.

Re^3: perllocale weirdness, bug, or...?
by Anonymous Monk on Oct 20, 2010 at 14:21 UTC
    Well what is your locale?
      Perl 5.8.8:
      
      $ locale
      LANG=en_US.UTF-8
      LC_CTYPE="en_US.UTF-8"
      LC_NUMERIC="en_US.UTF-8"
      LC_TIME="en_US.UTF-8"
      LC_COLLATE="en_US.UTF-8"
      LC_MONETARY="en_US.UTF-8"
      LC_MESSAGES="en_US.UTF-8"
      LC_PAPER="en_US.UTF-8"
      LC_NAME="en_US.UTF-8"
      LC_ADDRESS="en_US.UTF-8"
      LC_TELEPHONE="en_US.UTF-8"
      LC_MEASUREMENT="en_US.UTF-8"
      LC_IDENTIFICATION="en_US.UTF-8"
      LC_ALL=
      
      Perl 5.10.1:
      $ locale
      
      LANG=en_US.UTF-8
      LC_CTYPE="en_US.UTF-8"
      LC_NUMERIC="en_US.UTF-8"
      LC_TIME="en_US.UTF-8"
      LC_COLLATE="en_US.UTF-8"
      LC_MONETARY="en_US.UTF-8"
      LC_MESSAGES="en_US.UTF-8"
      LC_PAPER="en_US.UTF-8"
      LC_NAME="en_US.UTF-8"
      LC_ADDRESS="en_US.UTF-8"
      LC_TELEPHONE="en_US.UTF-8"
      LC_MEASUREMENT="en_US.UTF-8"
      LC_IDENTIFICATION="en_US.UTF-8"
      LC_ALL=
      
      

      Krambambuli
      ---

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://866335]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2014-10-25 13:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (143 votes), past polls