Well, I generally prefer to break things into more verbose code to make life easier 2 years down the road (or next week) when I have to change something.
Too, experience said my approach should be faster since more but easier (for Perl) regexes are typically faster than one complex one.
Just out of curiosity I ran a test and Benchmark confirmed my suspicion.
I set up the test with each sub populating $string from a global, processing it and returning the results.
With 10,000,000 iterations it's around 8.75 seconds for the one liner, and around 4.75 for my multi-line example on my machine.
I fiddled the code a bit to see if minor variations made any difference with little change in the times in either approach.
So, a little less than twice as fast in execution time...
Not a big deal at all with any reasonable number of string matches, but a little here, a little there...
Anyway, the OP was presented with several options. Life is good.
\s
|