Jessee Parker wrote:

> Sorry to make this a little clearer, I want to find the delimiter and then
> process what's past the delimiter. So all the html code would go into a
> variable and then all the text would go into a different variable.  Sorry
> for the confusion.
> 
> Jessee

try the following:

#!/usr/bin/perl -w
use strict;

my $html = 0;
my $text = 0;
my @html;
my @text;

open(FOO,'foo.txt');
while(<FOO>){
        $html =1 and last if(/^##\s+html\s+##/i);
        $text =1 and last if(/^##\s+text\s+##/i);
}

while(1){
        if($html){
                while(<FOO>){
                        last if(/^##\s+text\s+##/i);
                        push(@html,$_);
                }
                last if(eof(FOO));
                $html = 0;
                $text = 1;
        }
        if($text){
                while(<FOO>){
                        last if(/^##\s+html\s+##/i);
                        push(@text,$_);
                }
                last if(eof(FOO));
                $html = 1;
                $text = 0;
        }
}

close(FOO);

print "HTML @html\n";
print "TEXT @text\n";

__END__

it can even handle mixed section like:

## HTML ##
html 1
html 2
html 3
## TEXT ##
text 1
text 2
## HTML ##
HTML 1
HTML 2
## TEXT ##
TEXT 1
TEXT 2

david

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to