my $infile = "A.txt"; my $outfile = "B.txt"; open my $in_fh, '<', $infile or die "Couldn't open $infile for reading: $!\n"; open my $out_fh, '>>', $outfile or die "Couldn't open $outfile for appending: $!\n"; { local $/ = \65536; # read 64kb chunks while ( my $chunk = <$in_fh> ) { print $out_fh $chunk; } }