@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]);
Try using an intermediate stage for the mapping of values.
@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);
This should work and create a hash containing key => value pairs you are after for both the header and record.
Note: Untested
UnderMine

In reply to Re: Dreaded Symbolic References by UnderMine
in thread Dreaded Symbolic References by SkipHuffman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.