I have an input file which has many subrecords. The subrecord type is
denoted by the first 4 characters of the file. The rest of the line is
formatted like similar to the way that "pack" would format one. That is,
each data point in a subtype is always at the same offset for the same
length. E.g. 10 characters starting at offset 30, or some such. What I'm
considering is using "unpack" and having a hash contain the unpack
template based on the subrecord type. Something like:
while (<FH>) {
my $subrec = substr($_,0,4);
my @values = unpack $template{$subrec}, $_;
...
}
Earlier in the code, I would have created the %template hash which would
have the template associated with the $subrec from the input file.
Is this a decent way to do this? Is there a better way?
--
--
Maranatha!
John McKown
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>