in reply to Counting the number of items returned by split without using a named array
Another way that avoids a named array.
$entries = @{[ split /\s+/ ]};
Also, split /\s+/ is the similar to as the slightly magical split ' ', except undefs from leading whitespace are suppressed.
In turn, split ' ' is the same as split with no arguments, so you could reduce your code to:
$entries = @{[ split ]};
If you don't have leading whitespace, or don't want to count the undef any leading whitespace would produce as an entry.
|
---|