Thanks for all the replies above. You pointed out correctly that the input record separator cannot take regular expression. If "\s+" is taken out, indeed, the array has only one (the last one) element because all the previous elements is replaced by the last one. But, if "\s+" is kept, the array has all the elements. If you run my split.pl above on this simple input file:

Query= M01133:26:000000000-A6UCG:1:1101:22656:1128 1:N:0:1+@M01133:26:000000000-A6UCG:1:1101:22656:1128 2:N:0:1 Block1 Query= M01133:26:000000000-A6UCG:1:1101:22656:1130 1:N:0:1+@M01133:26:000000000-A6UCG:1:1101:22656:1130 2:N:0:1 Block2

You'll see the array has two elements and they are the correct ones. The result is here:

1 ---------------------- M01133:26:000000000-A6UCG:1:1101:22656:1128 1:N:0:1+@M01133:26:000000000-A6UCG:1:1101:22656:1128 2:N:0:1 block 1 2 ---------------------- M01133:26:000000000-A6UCG:1:1101:22656:1130 1:N:0:1+@M01133:26:000000000-A6UCG:1:1101:22656:1130 2:N:0:1 block 2

Actually, it produced 3 elements. The first element was an empty one. I added a line of script to skip it.

Chris, I ignored use strict, etc. just for testing this error. This split function is a part of my large script that worked perfectly until I got that particular input file. I just wrote a simple testing script to find out what the problem is

Laurent, that particular line is just like all other lines at the same position, nothing special about it.

By the way, I have two input files that do not work individually. However, if I combine them together to produce a larger file, the combined input file worked. That is strange.


In reply to Re^2: input record separator and split by frednc_2014
in thread input record separator and split by frednc_2014

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.