in reply to Sorting within a file

UNIX style:
perl -e 'push @file,$_ while<>;print sort {$a <=> $b} @file' test.txt
Dos style:
perl -e "push @file,$_ while<>;print sort {$a <=> $b} @file" test.txt
Results:
1 b005824 134 b005376 402 astamen 972 achin00 181847 azeleke 1260896 abadeno


Replies are listed 'Best First'.
Re^2: Sorting within a file
by RazorbladeBidet (Friar) on Mar 04, 2005 at 20:56 UTC
    How about

    perl -e "@file=<>; print sort { $a <=> $b } @file" test.txt
    --------------
    It's sad that a family can be torn apart by such a such a simple thing as a pack of wild dogs
      Or:
      perl -e "print sort {$a <=> $b} <>" test.txt


Re^2: Sorting within a file
by dmorelli (Scribe) on Mar 04, 2005 at 21:01 UTC
    Oh, now you've done it, got me started with the golf:

    perl -e 'print sort {$a <=> $b} <>' test.txt

Re^2: Sorting within a file
by Anonymous Monk on Mar 04, 2005 at 20:59 UTC
    UNIX style: perl -e 'push @file,$_ while<>;print sort {$a <=> $b} @file' test.txt Dos style: perl -e "push @file,$_ while<>;print sort {$a <=> $b} @file" test.txt Results: 1 b005824 134 b005376 402 astamen 972 achin00 181847 azeleke 1260896 abadeno Is this on the commad line? How would I incorporate this into my scrip +t? Thanks for the help.
      Put this code in your program file:
      use strict; print sort {$a <=> $b} <> __END__ Usage example: sort.pl data.txt


      Surely "Unix-style" would be $ sort -n file.txt?