in reply to Re^4: How can I test for the representation of an integer?
in thread How can I test for the representation of an integer?

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.