O glorious ones.

Ok, enough ass kissing.

I'm not a newbie, but sure feel like it. I'd like to know if there is any Perl package that deal with COBOL layout conversions.

I've wrote a few attempts over the years, but everytime I have one working for one project, it seems that the next project's layout if different enough to trigger a rewrite. I obviously don't know enough about COBOL (and would like to keep wallowing in my ignorance if possible) to write a generic layout parser which includes data conversion.

Here are the issues I am trying to deal with:

EBCDIC -> ASCII - Can't use 'dd' since I only want to convert non comp fields.

Comp fields, depending on which machine (endian wise) the data comes from.

Repeating fields.

Redefined fields.

Implied decimal.

88 levels for validation.

I've used the EBCDIC Perl libs which seem to work (but SLOW). I've actually split out the binary vs text data in the past, ran the text through a 'dd' conversion to ASCII and then joined the binary back in, and then attempted to deal with the comp field via varous unpack hacks. Twas nasty.

Redefines a another killer. I used to the in 'C' unions, so I understand them, but I have a tough time twisting them into Perl style hash ref records.

So, is this here (CPAN, etc) already and I simply missed it?

Also, due to data size, is this even reasonable? I may have to convert 500 million records on an on-going monthly basis. Should I accept the fact I'll need a hardcoded solution and just go from there?

In reply to COBOL Layout parsing by broomberg

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.