perl -le 'print for " THIS is a variable number of words, spaces and punctuation. " =~ /\w+/g' THIS is a variable number of words spaces and punctuation