in reply to Switch.pm gotchas?

You want real life experience?

Don't

Disclaimer: my use of Switch is about 18 months old. I'm not sure how actively it has been developed since then. My impression was that it works as advertised for little hello world scripts, but in bigger pieces of work, it seems to introduce garbage behind the scenes (due to source filtering), and the parser barfs on perfectly valid code.

Symptoms usually involved the fact that the parser thought it was coming out a string (single or double quoted) when in fact it was going into one, or vice versa. (update: reading broquaint's reponse... "Yes, exactly!" The syntax errors in question are miles away from the switch statement).

Change a line around, and an error crops up somewhere else. It was most infuriating, and eventually any attempt to use it in a non-trivial script resulted in failure.

Some time after that, Petruchio posted Help Debug Switch.pm! but I must admit that I had neither the time nor inclination to go back and try again. Maybe it works better these days, but the alternate P5 ways of implementing a switch are ok by me. I'll wait for P6 for the real thing.


print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'