in reply to Best way to append bigger files

Here is a try without File::Copy.

#!perl my $blocksize = (stat'.')[11] || 4096; open ( my $s, "<", "source" ) or die "Could not open source file: $!\n +"; open ( my $d , ">>", "dest" ) or die "Could not open destination file +: $!\n"; my $buffer; do { local $/ = \$blocksize; print {$d} $buffer while ( $buffer = <$s> ); }
English is not my mother tongue.
Les tongues de ma mère sont "made in France".

Replies are listed 'Best First'.
Re^2: Best way to append bigger files
by Anonymous Monk on Jul 24, 2012 at 17:01 UTC
    Aren't these time consuming ways?
      Aren't these time consuming ways?

      Perhaps. This is something to test. If portability is not a priority, system "cat source >> dest" is probably better with unixes. OP wants to avoid memory issue:

      OP: Finally, I would want to know the right and best way to append a to another file with out consuming memory.

      So I presume read/write in buffer corresponding to blocksize is a good choice if we can know the good one. With files of such size (terrabytes) there is a question: do I really have to append files? :)

      English is not my mother tongue.
      Les tongues de ma mère sont "made in France".