So I guess you want the count rather than the match (since you didn't specify). In that case, just force scalar context:
$ perl -MData::Dumper -e 'print Dumper(scalar ("2" =~ /(2)/));' $VAR1 = 1;
Update: As per haukex's correction the scalar context simply forces true/false rather than the count of matches. The above strategy still applies if this (whether the regex is a match or not) is all that you really want to test.
In reply to Re^5: How can I test for the representation of an integer?
by hippo
in thread How can I test for the representation of an integer?
by sm@sh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |