I need to write a script which would carry tar.gz archive in itself, which upon running it will save to a file on filesystem.
This script will be run under Windows environment.
I've decided to use __DATA__ section in order to store file contents.
However, I cannot later read the whole contents. File which I write is binary (tried both .dll and .tar.gz), and both contain SUB symbol (Notepad++ shows it that way). As I understand, it is equal to Ctrl^Z, and perl treats it as EOF and stops reading rest of the DATA.
But I need the whole data to be read and written to file. Any ideas how that can be accomplished?
Here is sample code (I already tried like 20-30 different ways, all with the same result):
my $outfile = "$HF_DIR/binary_copy.dat"; open (OUTFILE, ">", $outfile) or die "Not able to open the file for wr +iting. \n"; binmode (OUTFILE); binmode(DATA); do { local $/; print OUTFILE <DATA>;} ; close (DATA) or die "Not able to close the file: DATA \n"; close (OUTFILE) or die "Not able to close the file: $outfile \n";
and at the end there is __DATA__ section, with all the binary data:
__DATA__ ..binary data....SUB character......binary data... ......
So, perl only reads and writes til the first SUB character. And I need it to read and write all of the data.
Any help would be very much appreciated! Thank you in advance...
UPDATE: I decided to use base64 encryption and now all works, thanks for all your help guys!| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |