Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Best way to append bigger files

by brx (Pilgrim)
on Jul 24, 2012 at 15:21 UTC ( [id://983437]=note: print w/replies, xml ) Need Help??


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".

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://983437]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-19 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found