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++; }