in reply to Counting in regular expressions

If you want to use a regular expression, I believe that you're going to have to consume the original string, ala:
use strict; use warnings; my $count; # get $input from some place $input =~ s/^\s+//; # dump leading whitespace while ($input =~ s/[^\s]+\s+//) { ++$count; } ++$count if ($input =~ /./); # catch the last word
but, I think, what you really want is 'split':
my @array = split /\s+/, $input; $count = scalar (@array);
--
Wade