In the "perverse" category:
I wonder what's more common, the situation described by the OP or the need to know the sequence number of the match? If the former is more common, then I think one could make the case for having the match of the right operand return a string of the form '0En' instead of the current 'nE0'. Then, all that would be required to satisfy the OP's request would be to prepend 0+, or better yet, a minus sign, in front of the .. expression:use strict; use warnings; my @aap = qw( 0aap 0noot 1mies 2mies 0aap 0noot 1mies 6mies ); for (@aap) { print "$_\n" if - reverse '0' . (/^1(.*)/ .. /^0(.*)/); } __END__ 1mies 2mies 1mies 6mies
whereas if one wanted to keep the line matching the right operand one would omit the 0+ or minus sign:if ( -(/^1(.*)/../^0(.*)/) )
Those who actually wanted the match number, would have to scrape it off the return value:if ( (/^1(.*)/../^0(.*)/) )
I've tested this scheme a bit, and it seems to work; please let me know if I missed some corner (or not-so-corner) cases.if ( ( /^1(.*)/../^0(.*)/ ) =~ /(\d+)$/ ) { # $1 contains the sequence number of match
the lowliest monk
In reply to Re^2: .. operator and not including the condition of right operand
by tlm
in thread .. operator and not including the condition of right operand
by eXile
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |