in reply to if ($2) behaves differently than if (defined $2)

Since $2 refers to (\d{0,2} it seems that it actually matches zero occurrences of a digit, so $2 is the empty string.

An empty string is defined, but evaluates to false.