$_ = 254; my $r = qr{ ^ # regex bound to start of line ((?>\d+)) # what to capture, don't backtrack: (?> ) (??{ $1<255 && $1>233 # what is looked for ? '' # if yes, let the regex succeed : '(?!)' # if no, let the regex bail }) }x; print "true ($1)" if /$r/;