open(FH,"file.exe"); binmode(FH); my $binary; while() { $binary .= $_; } close(FH); open(FH,">newfile"); binmode FH; #<---- Add this and it works just fine :) print FH $binary; close(FH);