in reply to the best way to separate a string into words
For one definition of "split" and "words", I'd use:
my @words= $string =~ /(\w+(?:'\w+)*)/g;
Which would give you words like qw( split and words I'd use ) not like qw( "split" and "words", ) nor like qw( words I d use ).
Update: Or even, allow hyphenated-word capturing:
my @words= $string =~ /(\w+(?:[-']\w+)*)/g;
- tye
|
|---|