in reply to Dreaded Symbolic References
Try using an intermediate stage for the mapping of values.@HeaderRecordNames = qw/$RequestYear $RequestMonth $RequestDay $Requ +estSequence $RecordType $RecordSequence $Record/; @HeaderRecordLengths = qw/A2 A2 A2 A4 + A2 A2 A1486/; ... my (@HeaderRecordNames) = unpack(@HeaderRecordLengths, $_); my (@RecordNames[$Recordtype])=unpack(@RecordLengths[$RecordType]);
This should work and create a hash containing key => value pairs you are after for both the header and record.@HeaderRecordNames = qw/RequestYear RequestMonth RequestDay RequestS +equence RecordType RecordSequence Record/; $HeaderRecordLengths = q/A2A2A2A4A2A2A1486/; ... my @head = unpack($HeaderRecordLengths, $_); my %Header = map {$HeaderRecordNames[$_] => $head[$_]} (0..$#head); my @data = unpack($RecordLengths[$head{RecordType}], $Header{Record}); my %Record = map {$RecordNames[$_] => $data[$_]} (0..$#data);
|
|---|