Hi monks,

I am trying to split a large file into an array of record using $/. My split.pl is the following

#!/usr/bin/perl -w $input_blast = $ARGV[0]; $/ = "\nQuery=\s+"; open (IN, "$input_blast"); while (<IN>) { chomp; @blastblock = split(/Query=/, $_); } $total_number = 0; foreach $blastresult (@blastblock) { next if ($blastresult =~ /^BLASTN/); $total_number++; print "$total_number ----------------------$blastresult\n"; }
part of the input file is like:
Database: NLngoRT_WT_PCRDB 1 sequences; 481 total letters 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 Length=501 ... (more content here, I deleted them so that this message is small) 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 Length=501 ... (more content here, I deleted them so that this message is small) -------------

This is a huge file. It has 72320825 lines. I set the record separator on "Query= " and then split the file into an array. When I ran my split.pl on it, I got this error message: "Split loop at ../DIR_TEST/split.pl line 12, <IN> chunk 1." It did not produce an array. However, if I created a smaller file by using "head -54725379 >small.txe". It worked fine. If I added one more line using "head -54725380 >small_plus_1.txe". I got the same error message as the original file. Not sure what causes this. Somehow it is related to the split function. Thanks.


In reply to 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.