in reply to Sorting files you Have read
First suggestion: use your system's sort routine. While I think the *ix sort is better than the Windows sort, both are reliable, and quite fast.
As for sorting a list in Perl:
use strict; # a good idea use warnings; # and another my $input = 'myinput.txt'; open(my $in, "<", $input) or die "Could not open $input because $!\n"; @unsorted = <$in>; chomp(@unsorted); # get rid of end-of-record markers close($in); @sorted = sort @unsorted;
will sort the @unsorted array, based on the entire string, with the output going to @sort. Note that this requires a copy of the entire file be in memory, which may be a Bad Idea. There are several tutorials, for example, here and here. And of, course, here.
emc
At that time [1909] the chief engineer was almost always the chief test pilot as well. That had the fortunate result of eliminating poor engineering early in aviation.
—Igor Sikorsky, reported in AOPA Pilot magazine February 2003.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Sorting files you Have read
by GrandFather (Saint) on Nov 16, 2006 at 23:16 UTC | |
by brusimm (Pilgrim) on Nov 16, 2006 at 23:34 UTC | |
by robot_tourist (Hermit) on Nov 17, 2006 at 16:48 UTC | |
Re^2: Sorting files you Have read
by brusimm (Pilgrim) on Nov 16, 2006 at 23:07 UTC | |
by swampyankee (Parson) on Nov 16, 2006 at 23:36 UTC |
In Section
Seekers of Perl Wisdom