|laziness, impatience, and hubris|
Perl stops reading __DATA__ when meeting SUB character on Windowsby yfnecz (Novice)
|on Jan 02, 2014 at 23:06 UTC||Need Help??|
yfnecz has asked for the
wisdom of the Perl Monks concerning the following question:
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):
and at the end there is __DATA__ section, with all the 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!