in reply to How to sort a large flat file 90mb with PERL-- various ways/tradeoffs/watchouts
I agree that native unix sort is probably the best idea. You can install modules see A Guide To Installing Modules for details on how to install locally for yourself. If you have memory to burn you could just slurp the file into an array and sort it using perl's sort:
#!/usr/bin/perl open F, $ARGV[0] or die "Usage $0 infile > outfile\n"; @ary = <F>; close F; print for sort @ary;
This code will almost certainly be significantly slower and use a lot more memory than native unix sort. Because we output the sorted results immediately we only have one array in memory.....
cheers
tachyon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to sort a large flat file 90mb with PERL-- various ways/tradeoffs/watchouts
by theorbtwo (Prior) on Jun 30, 2004 at 07:16 UTC |