$totalcount += (split(/ /) - 1); #### $totalcount += split(' '); #### #!/usr/bin/perl -n while (m/\w+/g) { $count++ } END { print "count: $count\n" }