Hi,

I am having a major problem thinking my way out of this problem. I think the solution may be a simple one but my inexperiance with perl is really holding me back. I hope you folks can help me...

Here is the problem. I have very large files (reports) that are continually being generated the files can be on the order of 400 to 800 mb in length on average. In every file there will be a character set "DETS01". Essentially I want to create 2 new files. One with the info preceeding DETS01, one containing the info following DETS01 (essentially from DETS01 to EOF).

Getting the first part done is a breeze, using something on the order of:

#!/usr/bin/perl -w open (INPUT, "target.txt") || die "can't read from target:$!\n"; open (OUTPUT1, ">file1.txt") || die "can't write to file1.txt:$!\n"; # # while (<INPUT>) { last if $_ =~ /^DETS01/; print OUT "$_\n"; } close (INPUT); close (OUTPUT); exit;

I just can't seem to come to terms with scanning down to the DETS01 and then printing everything that comes after it to the EOF. I've tried using unless and until statements but I've got this freakin' mental block that just won't let me move forward with this. It seems so freakin' simple!!! I just can't get it!!!!

If someone can point me in the right direction I would be s o appreciative....

Thank You!!!! #


In reply to How to scan a file, find a character string and print from that string to EOF by 0p3nfac3

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.