my $outfile = "$HF_DIR/binary_copy.dat"; open (OUTFILE, ">", $outfile) or die "Not able to open the file for writing. \n"; binmode (OUTFILE); binmode(DATA); do { local $/; print OUTFILE ;} ; close (DATA) or die "Not able to close the file: DATA \n"; close (OUTFILE) or die "Not able to close the file: $outfile \n";