Usage: perl [switches] [--] [programfile] [arguments] -0[octal] specify record separator (\0, if no argument) -a autosplit mode with -n or -p (splits $_ into @F) -C[number/list] enables the listed Unicode features -c check syntax only (runs BEGIN and CHECK blocks) -d[:debugger] run program under debugger #### #!/usr/bin/perl -n s/[^\w]+/ /g; # replace the non words with space next if(/^\s*$/); # discard sentence with only spaces $totalcount += (split(/ /) - 1); # split the sentence using space and count it END{ print "Total: $totalcount<<\n"; }