On Wed, 30 Jul 2003 21:36:46 -0500, James E. Tilley wrote:
>Does
>
> if (/^BEGIN$/ .. (/^\s*$/ .. /^END$/) =~ /E/)
>
>do what you want?
s/BEGIN/START/ to plug it in the skeleton.
And yes, that's perfect. Quite elegant too. Very much so.
Here's my own solution:
my $pre;
while(<DATA>) {
if(my $count = (($pre = /^START$/) ..
(/^$/ && undef $pre, !$pre && /^END$/))) {
print "$count: $_";
}
}
What I don't particularly like about it, is how it needs an extra outer
scope variable, $pre, to hold a flag to store the intermediate
condition.
BTW with the additional variable $count capturing the result of the
expression, it's easier to keep track of what happens.
--
Bart.