http://www.perlmonks.org?node_id=547120


in reply to Re: Counting the number of items returned by split without using a named array
in thread Counting the number of items returned by split without using a named array

The =()= does work with matches:

$ perl -lpe '($_=()=/\s+/g)++' foo 1 bar baz 2 foo bar baz 3

But I would use split, especially with the smart behaviour provided by the default ' ' argument.