Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I would like to know the best way to append a file (huge,in Terra bytes) to another file.
Both source and destination could be of Terrabytes in Size.
As of now, am usinguse File::Copy; open ( my $s, "<", "source" ) or die "Could not open source file: $!\n +"; open ( my $d , ">>", "dest" ) or die "Could not open destination file +: $!\n"; copy($s, $d) or die "Could not copy source to dest : $!\n"; (close $s && close $d ) or die "Could not close file handles : $!\n";
But some time, the above code says "Could not close file Input/Output error", and destination file is corrupted. I've noticed the line Note that passing in files as handles instead of names may lead to loss of information on some operating systems; it is recommended that you use file names whenever possible. from http://search.cpan.org/~rjbs/perl-5.16.0/lib/File/Copy.pm
Am not sure, whether passing file handle to copy is causing this issue.
Finally, I would want to know the right and best way to append a to another file with out consuming memory.
Thanks in Advance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Best way to append bigger files
by brx (Pilgrim) on Jul 24, 2012 at 15:21 UTC | |
by Anonymous Monk on Jul 24, 2012 at 17:01 UTC | |
by brx (Pilgrim) on Jul 24, 2012 at 17:21 UTC | |
|
Re: Best way to append bigger files
by 2teez (Vicar) on Jul 24, 2012 at 15:18 UTC | |
|
Re: Best way to append bigger files
by locked_user sundialsvc4 (Abbot) on Jul 24, 2012 at 21:01 UTC | |
by chromatic (Archbishop) on Jul 24, 2012 at 22:06 UTC | |
|
Re: Best way to append bigger files
by BrowserUk (Patriarch) on Jul 25, 2012 at 20:17 UTC |