http://qs321.pair.com?node_id=11124602


in reply to How to Split on specific occurrence of a comma

The limit arg to split lumps the rest of the string into the last array entry. If you want n items, then split with a limit of n+1 and ignore or discard the last entry in the array.

Your code was also using a map to create an array ref, which is not needed here.

This updated snippet from your example code will give an array of two items:

@teams = split /,/, $line, 3; pop @teams;