in reply to Counting in regular expressions

Here's a very straight-forward way to do this:
my $digit_count = ($input =~ tr/[0-9]//); my $white_count; while ($input =~ m/\s/g) { $white_count++; } # note: can't use tr/\s// my $word_count; while ($input =~ m/\w+/g) { $word_count++; }
As is generally the case with perl, there are many ways to perform these tasks.