On Tue, Apr 17, 2001 at 01:33:39PM -0700, Paul Jasa wrote:

> I want to be able to divide up a text file by using specific
> words in the text, in other words, I'd like to be able to tell the script
> to:
> 
>       Read file ./FILE, and from that file, 


   my $file = do { local $/; <FILE> };   # slurp whole file


> create an array 


An array of what? 

I will assume an array of non-whitespace chunks.


>that starts
> from word (YYYY)  and ends in  word (ZZZ) as it reads from left to right.


   my $interesting = $1 if $file =~ /YYYY(.*?)ZZZ/s;
   my @chunks = split /\s+/, $interesting;

Oh. You wanted the endpoints included. So:

   my $interesting = "YYYY $1 ZZZ" if $file =~ /YYYY(.*?)ZZZ/s;

then.  :-)


-- 
    Tad McClellan                          SGML consulting
    [EMAIL PROTECTED]                   Perl programming
    Fort Worth, Texas

Reply via email to