http://www.perlmonks.org?node_id=899046


in reply to Re^4: Is there a way to avoid copy function from overwriting old contents?
in thread Is there a way to avoid copy function from overwriting old contents?

Why do you use File::Copy? I tested your code and, to my surprise, copy does append to a file if you open it for appending and copy to the filehandle.
copy "file1", $fh
But it's not documented in the POD, and it only works as a side effect of how File::Copy deals with filehandles. Why not do as others have suggested:
if (true) { open (my $fh, ">> RESULT_LOG"); open BATTERY, "<Battery_Status"; print $fh <BATTERY>; close BATTERY; } else {print "Error"}
It's a couple of extra lines, but you can use all built-ins, obviating the need for an external module.

My two cents.

--marmot