in reply to Alphanumeric sort

No sort required. A one liner:

C:\test>type junk.dat 1208782,abc 406744,def 367455,abc 283191,mps 226159,abc 197688,rxwz 137875,rxwz 115901,abc 107297,def 99213,mps perl -nlE"($n,$k)=split',';$h{$k}+=$n}{say$_,':',$h{$_}for keys%h" jun +k.dat mps:382404 def:514041 abc:1918297 rxwz:335563

But should you need the output sorted:

perl -nlE"($n,$k)=split',';$h{$k}+=$n}{say$_,':',$h{$_}for sort keys%h +" junk.dat abc:1918297 def:514041 mps:382404 rxwz:335563

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Alphanumeric sort
by jffry (Hermit) on Sep 21, 2011 at 22:06 UTC

    I am not seeing the -E flag on my Perl6 distro. I downloaded the latest Rakudo Star. I supposed you're getting the latest developer build?

    me@mybox:/tmp/me $ perl6 -E 'say "bob"' ===SORRY!=== Unable to open filehandle from path '-E' me@mybox:/tmp/me $ perl6 -e 'say "bob"' bob me@mybox:/tmp/me $ perl6 -v This is Rakudo Perl 6, version 2011.07 built on parrot 3.6.0 0 Copyright 2008-2011, The Perl Foundation
      I am not seeing the -E flag on my Perl6 distro.

      Neither the code I posted nor anything in this thread mentioned Perl 6. Strictly Perl 5 only.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        Gotcha now. Thanks for the clarification. I am missing the modern Perl 5 versions. I am stuck with Perl 5.8.8. for the most part.

        I have been assuming that any use of say was an indication of Perl6. I now presume that was a false assumption.