in reply to Text file filtering

If I understand your question right, something like this may do what you want:

$your_data =~ /\+Header1(.|\n+)-Header1\n\+Header2(.|\n+)-Header2\n\+H +eader3(.|\n+)-Header3\n/;

I wouldn't suggest using that as anything but a starting point, though. There are regex options for changing the . operator to match \n's, and you may want to consider doing a line by line parse (and having boolean--i.e., flag--variables to tell you what section you're in).

The last suggestion might be started like this:

while ($line = <your_file_handle>) { if($line =~ /^\+Header1/) { $header1 = 1; next } # if +Header1 has its own line use next elsif($line =~ /^-Header1/) { next } else { $header1 = 0 } . . . if($header1) { $h1_data[$index++] = $line; } . . . }

Again, these are just quick things to get you started thinking; you may want to look at this site and search for regex, or look at the perlman pages for more information regarding them.

Replies are listed 'Best First'.
Re: Re: Text file filtering
by surfmonkey (Acolyte) on Jun 27, 2002 at 15:37 UTC
    Thanks, what I want to do is match the block of data between the two headers so that I can put it into a separate variables so that at the end I have three variables containing the data from between the separate headers. I just can't get my head around using regexp's :o(