in reply to
Reg Ex exercise
| stands for "or" only inside a regular expression. Outside, you have to use || or or. The vertical bar alone is a "bitwise or", see perlop. No "or" is needed, though:
my $r = qr/^-? # Can start with a minus.
(:? # Non capturing group.
[0-9]+ # Digits. Does not match Unicode digits as \d
(?: # Another group, this one will be optional.
\. # The dot. Backslashed to lose its special me
[0-9]+ # Digits again.
)? # End of the inner group, the ? makes it opti
) # End of the outer group.
$ # And nothing more.
like ($_, $r) for qw/ 4 -7 0.656 -67.35555 /;
unlike($_, $r) for qw/ 5. 56F .32 -.04 /;