Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: How to Split on specific occurrence of a comma

by swl (Parson)
on Dec 03, 2020 at 21:35 UTC ( [id://11124602]=note: print w/replies, xml ) Need Help??


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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11124602]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-03-29 08:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found