tariqahsan has asked for the wisdom of the Perl Monks concerning the following question:
I can have any number of these STMT blocksRULE=test BEGIN NUMOFRULES=2 STMT1=BEGIN A B C STMT1=END STMT2=BEGIN X Y Z STMT2=END
My code snippet is like -
Any idea how I can achieve this?open (RULE, "$rulefile") || die "Can't open $rulefile for reading $!\n +"; while ( defined ($_ = <RULE>) ) { if (/RULE=$rule/../^END$/) { chomp $_; if ($_ =~ /^NUMOFRULES/) { # Get the number of rules @rulenos = split(/=/); } for ($i = 1; $i <= $rulenos[1]; $i++) { if (/^STMT$i=BEGIN$/../^STMT$i=END$/) { if ( !($_ =~/^STMT/)) { print $_; } } } } } -Getting- A A B B C C ... -Want to get- A B C ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem in using range operator
by tlm (Prior) on May 03, 2005 at 22:18 UTC | |
|
Re: Problem in using range operator
by Transient (Hermit) on May 03, 2005 at 22:11 UTC | |
by tariqahsan (Beadle) on May 04, 2005 at 03:13 UTC | |
|
Re: Problem in using range operator
by johnnywang (Priest) on May 03, 2005 at 22:50 UTC |