Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi again monks. I must ask yet again for some advice though you have tought me allot to this point. I have a file called file1.txt containing the following:
A0 B0 C0 A1 A0 B2 C0
And I want to take out the first A0 C0 and every thing in between write it to file2.txt then take out the next A0 C0 and everything in between and write it to file3.txt so file1.txt contains A1, file2.txt contains A0 B0 C0 and file3.txt contains A0 B2 C0. Any help with this greatly appreciated! Thanks in advance

Replies are listed 'Best First'.
Re: Extracting blocks of text into separate files
by Aristotle (Chancellor) on Jul 25, 2002 at 21:06 UTC
    Sounds like something along the lines of
    $_ = q(A0 B0 C0 A1 A0 B2 C0); my @block = split /(A0.*?C0)/;
    And then you do whatever you want with each element of @block. See perldoc -f split.

    Makeshifts last the longest.