#!perl -l my $str = "here are some words"; my $count = @{[ $str =~ /\S+/g ]}; print $count;