in reply to Re: Succinct switch statement
in thread Succinct switch statement
The modifications involves the enclosing of the condiitons and actions inside a labelled block and reworking the next statements e.g.
Also, personally, I would rewrite it as followswhile ($_ = $ARGV[0]) { SWITCH: { /^(-V|-?-verbose)$/o and do{shift; $verbose=1; ...; last SWITCH +}; /^(-v|-?-negate)$/o and do{shift; $negate=1; ...; last SWITCH +}; ... /^--?$/o and do{shift; ...; last SWITCH +}; } }
Update:PARSE: while (@ARGV) { local $_ = shift; SWITCH: { /^(-V|-?-verbose)$/o and do { $verbose=1; ...; last SWITCH }; /^(-v|-?-negate)$/o and do { $negate=1; ...; last SWITCH }; ... /^--?$/o and do { ...; last PARSE }; } }
Added correct loop termination (using PARSE label) for specific instance offered above.
|
|---|