in reply to Sort lines in a file
This is well known, but DON'T use $&, as it will grind your program to a complete halt.
Next, do the sorting while you're processing the input:
open(my $IN,'<','in.txt') || die "cannot open in.txt - $!\n"; my @output; while(<$IN>) { next if m/^\n/; push (@output, $_); @output = sort @output; }
Software speaks in tongues of man.
Stop saying 'script'. Stop saying 'line-noise'.
We have nothing to lose but our metaphores.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sort lines in a file
by toolic (Bishop) on Feb 14, 2008 at 15:47 UTC | |
|
Re^2: Sort lines in a file
by MidLifeXis (Monsignor) on Feb 14, 2008 at 16:37 UTC | |
by blackdragoen (Novice) on Feb 15, 2008 at 04:33 UTC |