http://qs321.pair.com?node_id=700599


in reply to Re^4: Sort log file alphabetically
in thread Sort log file alphabetically

while(<DATAOUT>) {

attempts to read from DATAOUT, which you just opened for writing only. As a result, the test (successful read from DATAOUT) fails and the body of your while is not executed. If you had use warnings;, you would have been told that DATAOUT was open only for output.

You don't need that while loop, the for loop will do the job you want done.

You should always

use strict; use warnings;
It's also a GoodIdea to

open(FH, ....) or die "error opening FH: $!";