G
gavs
Hi,
I am fairly new to perl and need to split a fairly large file that
contains no newlines. The records contained in this file is fixed
length. I have written the following code to split this long record
into 600 byte long records and appending a newline. After executing
this program, the file size doubles.
For example: a record in this file can be split up into 3 records of
600 byte length; hence the original length of this file is 1800 bytes.
size = size of the original file.
while($bytes_read < $size) {
my $record;
$bytes_read += read(FIN, $record, $record_len, $offset);
print "Bytes read # $bytes_read, OFFSET=$offset\n";
$record .= "\n";
print FOUT $record;
$offset += $record_len;
}
fclose(FIN);
fclose(FOUT);
Viewing the out file with vi generates the following:
"a" 3 lines, 3603 characters (1800 null characters)
Where are extra 1800 bytes coming from? How do I get rid of them?
Thanks.
gavs
I am fairly new to perl and need to split a fairly large file that
contains no newlines. The records contained in this file is fixed
length. I have written the following code to split this long record
into 600 byte long records and appending a newline. After executing
this program, the file size doubles.
For example: a record in this file can be split up into 3 records of
600 byte length; hence the original length of this file is 1800 bytes.
size = size of the original file.
while($bytes_read < $size) {
my $record;
$bytes_read += read(FIN, $record, $record_len, $offset);
print "Bytes read # $bytes_read, OFFSET=$offset\n";
$record .= "\n";
print FOUT $record;
$offset += $record_len;
}
fclose(FIN);
fclose(FOUT);
Viewing the out file with vi generates the following:
"a" 3 lines, 3603 characters (1800 null characters)
Where are extra 1800 bytes coming from? How do I get rid of them?
Thanks.
gavs