use autodie; use File::Copy 'copy'; my $append = ...; # If true append, else overwrite. open my $fh, $append ? ">>" : ">", LOG; copy "tmp", $fh;