0p3nfac3 has asked for the wisdom of the Perl Monks concerning the following question:
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!!!! #
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to scan a file, find a character string and print from that string to EOF
by tadman (Prior) on Aug 30, 2002 at 18:11 UTC | |
Re: How to scan a file, find a character string and print from that string to EOF
by myocom (Deacon) on Aug 30, 2002 at 16:59 UTC | |
Re: How to scan a file, find a character string and print from that string to EOF
by the pusher robot (Monk) on Aug 30, 2002 at 18:07 UTC | |
Re: How to scan a file, find a character string and print from that string to EOF
by Anonymous Monk on Aug 30, 2002 at 18:14 UTC |