my ($min, $max) = (35, 50); if ( m/^(\d+)(??{ $^N >= $min && $^N <= $max ? '' : '(?!)'})$/ ){ print "$_ is between $min and $max\n"; }