$ perl -E 'say for split /\W+/, " THIS is a variable number of words, spaces and punctuation. "' THIS is a variable number of words spaces and punctuation #### $ perl -E 'say for split /[ ,.]+/, " THIS is a variable number of words, spaces and punctuation. " =~ s/^[ ,.]*//r' THIS is a variable number of words spaces and punctuation