in reply to Between-text range operator problem

First, this type of thing was discussed recently in read between two strings, so maybe that will be of help.

Secondly, if people are going to be fools, then you probably have to do something besides use the range operator. A regular state system seems to work well:
my %pair = ( 'foo' => 'bar', 'jack' => 'daniels', 'Tom' => 'Jerry', 'BEGIN' => 'END', ); my %data; my $tail; my $type; while (<FILE>) { chomp; s/\s+$//; # Clean up invisible stuff if ($pair{$_}) { $type = $_; $tail = $pair{$_}; } elsif ($_ eq $tail) { undef $type; } push (@{$data{$type}}, "$_\n"); }
Now you can get the stuff out of the %data hash, or deal with it some other way. YMMV.

Replies are listed 'Best First'.
Re: Re: Between-text range operator problem
by jlongino (Parson) on May 17, 2002 at 02:19 UTC
    Thanks for the reply tadman. The link, though somewhat related, doesn't really address the header/footer failure aspect. I think I understand your example but I'll have to play with it some to be sure.

    --Jim