The (*F) operator was introduced with 5.10. Prior to that, (?!) can be used.
>perl -wMstrict -le "for my $n (4 .. 9) { my $str = qq{I have 5 apples, $n oranges, and 8 limes.}; print qq{'$str'}; next unless $str =~ m{ (\d+) \s+ apples \D+ (\d+) \s+ oranges \D+ (\d+) \s+ limes (?(?{ $1 < $2 && $2 < $3 }) | (*F) ) }xms; print qq{'$2'}; } " 'I have 5 apples, 4 oranges, and 8 limes.' 'I have 5 apples, 5 oranges, and 8 limes.' 'I have 5 apples, 6 oranges, and 8 limes.' '6' 'I have 5 apples, 7 oranges, and 8 limes.' '7' 'I have 5 apples, 8 oranges, and 8 limes.' 'I have 5 apples, 9 oranges, and 8 limes.'
In reply to Re^3: How to use "less than" and "greater than" inside a regex for a $variable number
by AnomalousMonk
in thread How to use "less than" and "greater than" inside a regex for a $variable number
by Polyglot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |