in reply to Is there a way to avoid copy function from overwriting old contents?

This ought to work:
use autodie; use File::Copy 'copy'; my $append = ...; # If true append, else overwrite. open my $fh, $append ? ">>" : ">", LOG; copy "tmp", $fh;
Or:
my $append = ...; # If true append, else overwrite. system "cat tmp " . ($append ? ">>" : ">") . " LOG" and die;

Replies are listed 'Best First'.
Re^2: Is there a way to avoid copy function from overwriting old contents?
by justkar4u (Novice) on Apr 12, 2011 at 17:45 UTC
    Hi all, Thanks for the help. @Java fan : Thank you, your suggestion with slight modification seems to work best for my case. -Ram