use Regexp::Common qw/ number /; my $num1 = qr{^ (?> ($RE{num}{dec}) ) (?(?{ $^N != '1' })|(?!)) }x;