Can't be sure, but it sounds like what you are looking at are files using \n as the segment terminator and '*' as the element separator. With \n as the segment terminator, it's natural to just read the segments as separate lines.

These are good choices for the terminator, even recommended by the standards, IIRC. You're in luck in that your partners haven't used non-printable characters so this data is easy to read by just eyeball inspection. Oh, if you're trying to parse out the elements (the data between the '*'s), remember to quote the '*' properly in the split command. That's one pitfall of using '*', but an easy one to overcome.

The 'BEG', 'N1', 'N3', 'PO1' are called Segment Identifiers. Each field in those segments is defined in terms of allowable values (alpha, numeric, special tables of values, etc.), but there is a lot of latitude on how to use these standards. This latitude is typically nailed down in ICs (Implementation Conventions). In this discussion I have some links to some sample ICs used by the Government and others. These Sample ICs are actually based on the ASC X12 documents.

Ask around and see if your trading partners have written up ICs. It may well be the case that they haven't, in which case you have to reverse engineer them from their use. Getting this right can be complicated.


In reply to Re: Re: 850 EDI Help by jordanh
in thread 850 EDI Help by the_Don

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.