in reply to Re: Sorting within a file
in thread 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 Is this on the commad line? How would I incorporate this into my scrip +t? Thanks for the help.

Replies are listed 'Best First'.
Re^3: Sorting within a file
by sh1tn (Priest) on Mar 04, 2005 at 21:23 UTC
    Put this code in your program file:
    use strict; print sort {$a <=> $b} <> __END__ Usage example: sort.pl data.txt


Re^3: Sorting within a file
by DrHyde (Prior) on Mar 07, 2005 at 09:33 UTC
    Surely "Unix-style" would be $ sort -n file.txt?