in reply to Re^2: Parsing a command-line string into an array
in thread Parsing a command-line string into an array
I would prefer to rely on a module than string-splitting.
We don't need a module to parse the grammar I suggested. The grammar is just that simple. That's the point.
All we're doing is parsing the provided value to separate it into a name and a value. And we know the names can't contains spaces or punctuation (except perhaps _ or -).
This is the same approach curl uses.
curl ... -H 'Header1: ...' -H 'Header2: ...' ...
You could leave out the initial dash if you want (-X 'y'/-X 'y ...').
You could use equal signs instead of spaces if you want (-X 'y'/-X 'y=...').
Whatever. The specifics aren't important and are quite flexible since all you have to do is separate a name (with a very limited set of characters) from the rest.
The solution I presented does not "open a different can of worms". It in fact avoids doing so.
|
---|