$ths = ' this is a string'; $i = split(/\s/,$ths); print "$i\n"; #### $_ = ' this is a string'; my @words = split " "; print scalar @words, "\n"; # or you could go for this version :-) $_ = ' this is a string'; my $words =()= /(\S+)/g; print $words, "\n";