A word-count program that handles multiple spaces and tabs between words.
#!/usr/local/bin/perl $wordcount = 0; $line = <STDIN>; while ($line ne "") { chop ($line); @words = split(/[\t ]+/, $line); $wordcount += @words; $line = <STDIN>; } print ("Total number of words: $wordcount\n");