in reply to Re: Succinct switch statement
in thread Succinct switch statement

Whilst your code self-evidently works, it doesn't satisfy the general case (pun intended) since it will only work within a loop - with modifications, it can be made to work anywhere.

The modifications involves the enclosing of the condiitons and actions inside a labelled block and reworking the next statements e.g.

while ($_ = $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 +}; } }
Also, personally, I would rewrite it as follows
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 }; } }
Update:

Added correct loop termination (using PARSE label) for specific instance offered above.

A user level that continues to overstate my experience :-))