Skip Menu |

This queue is for tickets about the Sort-External CPAN distribution.

Report information
The Basics
Id: 13701
Status: resolved
Priority: 0/
Queue: Sort-External

People
Owner: CREAMYG [...] cpan.org
Requestors: perlprogrammer [...] shaw.ca
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.04
Fixed in: 0.05



Subject: finish(-outfile $file) produces empty file
When the finish method is called with the -outfile parameter, it doesn't write the contents of the cache to the file if no temporary files were required for the sort. Since fetch seems not to have this problem, that's what I used in the uploaded patch, which is a drop in replacement for sub finish. I doubt that this is a good solution. It has not been extensively tested. $Sort::External::VERSION is 0.04 ActiveState Perl 5.8.3 (binary build 809) Microsoft WinXP Home SP2 E-mail me if you'd like sample code to produce the error.
############################################################################## ### Sort all items, to an outfile if desired. ############################################################################## sub finish { my $self = shift; $self->_consolidate_sortfiles('final'); ### If called with arguments, we must be printing everything to an ### outfile. if (@_) { my %args; while (@_) { my ($var, $val) = (shift, shift); croak("Illegal parameter: '$var'") unless exists $finish_defaults{$var}; $args{$var} = $val; } sysopen(OUTFILE, $args{-outfile}, O_CREAT | O_EXCL | O_WRONLY ) or croak ("Couldn't open outfile '$args{-outfile}': $!"); # for my $source_fh (@{ $self->{sortfiles}[-1] }) { # while (<$source_fh>) { # print OUTFILE # or croak("Couldn't print to '$args{-outfile}': $!"); # } # } my $stuff; print OUTFILE $stuff while ($stuff = $self->fetch); close OUTFILE or croak("Couldn't close '$args{-outfile}': $!"); } }