in reply to Switch CLI Parsing Question
Superficially looking at this problem, it seems to me that probably the best way to approach it is with a three-stage approach. First, you split the string by spaces into its four components. Then, you split the fourth component by commas. Finally, for-each element thus split, you are dealing with an easily-recognizable "a/b(-c?)" structure.
In other words don't try to do it all at once.
You also don't want to rely on things like $1 when each of those regular-expression operations will so-quickly redefine them. So, do things like:
my ($a,$b,$c,$d) = split/\s+/,$myrec;
where the tuple produced by "split" is immediately assigned to a corresponding tuple of discrete variables.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Switch CLI Parsing Question
by ewhitt (Scribe) on Nov 19, 2007 at 21:12 UTC |