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.
In reply to Re: Sort lines in a file
by Erez
in thread Sort lines in a file
by blackdragoen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |