I may be way out in left field here, but I have a suggestion that may help you to avoid abandoning the Perlish use of split. I'm surprised it hasn't been offered yet. ...maybe it's because I AM in left field. ;)

If your data is truly pipe delimited, perhaps you should read it in using the pipe as the record separator. Before slurping in this long datafile, add the line  $/ = "|"; prior to your file read. Then put your file read into a loop, and be sure to either process each line individually, or slurp it into an array now instead of a scalar. After you're done reading in the file, just to retain your sanity, change  $/ back to  "\n".

That's going to serve the function of having the file read already split your file on "|". Now you can process each pipe delimited line on its own as a much smaller, easier to use chunk.

Read the file in pre-split. Come to think of it, this does abandon the Perlish split, in favor of an even more Perlish approach (IMVHO).

I hope this helps.

Dave

"If I had my life to do over again, I'd be a plumber." -- Albert Einstein


In reply to Re: Alternatives to split? by davido
in thread Alternatives to split? by Perl Apprentice

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.