E
emcee2k
When I run the following code, it creates a 1063 byte file on Win32:
open(F, 'textfile.txt');
read(F, $txtPreview, 1024, 0);
close(F);
open(TL, '>textpreview.txt');
print TL $txtPreview;
close(TL);
There's 39 line breaks in the file it creates, so that explains the
file size of 1063 instead of 1024. However, with this code I expected
to get a file of 1024, but I still got 1063:
open(F, 'textfile.txt');
binmode(F);
read(F, $txtPreview, 1024, 0);
close(F);
open(TL, '>textpreview.txt');
print TL $txtPreview;
close(TL);
So what do I have to do to insure that the length argument to the read
function is treated as the amount of bytes to be read, rather than the
amount of characters?
open(F, 'textfile.txt');
read(F, $txtPreview, 1024, 0);
close(F);
open(TL, '>textpreview.txt');
print TL $txtPreview;
close(TL);
There's 39 line breaks in the file it creates, so that explains the
file size of 1063 instead of 1024. However, with this code I expected
to get a file of 1024, but I still got 1063:
open(F, 'textfile.txt');
binmode(F);
read(F, $txtPreview, 1024, 0);
close(F);
open(TL, '>textpreview.txt');
print TL $txtPreview;
close(TL);
So what do I have to do to insure that the length argument to the read
function is treated as the amount of bytes to be read, rather than the
amount of characters?