For the particular problem you're approaching, it looks like the structure of a list of pairs is quite adequate.

( Batch_Agency => { range => [ 1 .. 3] }, Batch_Date => { range => [ 4 .. 11] }, Batch_Type => { range => [ 12 .. 12 ] } }
With the list of pairs, you get the features: So it should be quite easy with a little processing both to format the records and to map the input given as array of hash refs to the right positions and shapes.

Beware of using the ranges as you mentioned (range => [1 .. 3]). They can become a burden to maintain as fields are added or change size. It would probably be more useful to work only with lengths and compute automatically the range (if needed). Something like length => 3 or format => 'A3'.

If you decide to avoid the suffering of writing and maintaining the code for producing these streams of fixed-format records, you may try some modules from CPAN. Among them, Data::FixedFormat and AnyData::Format::Fixed.


In reply to Re: Accessing an array of anonymous hashes by ferreira
in thread Accessing an array of anonymous hashes by thezip

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.