in reply to Re^3: perl ST sort performance issue for large file?
in thread perl ST sort performance issue for large file?
I am trying to run the code what you have mentioned. But this is resulting in "List form of pipe open not implemented at... +sort.pl line 19"(on my windows system).I came to know that "List form + of pipe open "is not supported on windows system. and I changed it t +o open $fh, "|sort $filename", or die; and the entire code looks like this: use strict; use warnings; my $filename = "sort_input"; my $fh; my $line; my $key; my $value; my $prev_key; my $prev_value; my $file_consolidated_sort= "sort_output"; my $FH_sorting; #open $fh, '-|', 'sort', $filename or die; open $FH_sorting, ">>$file_consolidated_sort" or die "$!"; open $fh, "|sort $filename", or die; chomp( $line = <$fh> ); ($prev_key, $prev_value) = split /,,/, $line; while (<$fh>) { chomp; ($key, $value) = split /,,/; if ($prev_key eq $key) { $prev_value .= $value; } else { print $FH_sorting $prev_key ,, $prev_value; ($prev_key, $prev_value) = ($key, $value); } } print $FH_sorting $prev_key,,$prev_value; close $fh; close $FH_sorting; Another point is that I am not able to write the resulted output to th +e output file handler.All sorted output is getting printed on the scr +een itself with the warning/error on screen "Use of uninitialized val +ue $line in chomp at line 25, 26 etc". I have not tried sorting with huge file(3GB) which is my actual requir +ement and have not tested for performance will improve or not. Parelelly I am looking into external sort
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: perl ST sort performance issue for large file?
by salva (Canon) on Apr 06, 2012 at 10:42 UTC |