in reply to Programmatically forcing a regexp to fail
/^(\d+)$ (?(?{ $^N % 3) })(?!))/x
works, but
/^(\d+)$/ && ($1 % 3 == 0)
is easier to read and maintain.
Note that in 5.10, you'll be able to use (*FAIL) instead of (?!), but you're better off with (?!) for backwards compatibility.
Note that $^N made its first appearance in rather recent 5.8, so you're better off using $1 for backwards compatibility.
|
|---|