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


in reply to split on commas

Not a beginner answer, but the "principled" way to solve this is to use a parser, not a regex.

Parse::RecDescent is such a parser.

However, as the other answers have said, there are ways to "cheat" around this without using a full blown parser. The cheats may be brittle... for example, what happens if you have brackets inside a bracket, and commas inside that? However they'll work for most purposes.