Writing your new file line by line is just fine. I'd arrange to set $\, the output record seperator, to "\n" just to avoid having to print it explicitly. You place the seperator at the front of each print, which I would avoid. You'll probably also want to set $, for the output fields.
You can get buffered input of your fixed length chunks by setting local $/ = \1034;. That will avoid the fussiness of working with read.
It'll look like this:
{ local ($\ , $, , $/, $_) = ("\n", "\t", \1034); my $somefmt = 'ccc v V '; # add the rest of the format open my $in, '<', '/path/to/original.dat' or die $!; binmode $in; open my $out, '>', '/path/to/outfile.txt' or die $!; while (<$in>) { my @data = unpack $somefmt, $_; # ... adjust @data print $out @data; } close $out or die $!; close $in or die $!; }
After Compline,
Zaxo
In reply to Re: Most efficient way to build output file?
by Zaxo
in thread Most efficient way to build output file?
by iKnowNothing
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |