in reply to Re: Pseudo-switch question
in thread Pseudo-switch question
For what's it's worth, I prefer either of the versions in the original node to this by a factor of about 1000.
I'd love to see the look on your replacement's face when they see such code.
You prefer having to come up with a label and then repeating "last LABEL" all over the place to a simple elsif ?? My mind boggles. Really.
And that indentation scheme is atrocious! (Okay, now I sound like that guy in Airplane!... Johnny, talking to the captain's wife, ya know?)
But, in all sincerity, I find it hard to express how distasteful I find that code. I boggled at it when it showed up in the documentation (I think it predates 'pod'). It has just gotten uglier over the years.
If there were some powerful, compelling advantage to it, then I might have a small amount of appreciation for it. I realize that it allows you to "fall through" somewhat like a switch/case, but it doesn't even emulate that very well.
[ And even beyond all of the awful style problems, the code isn't a very good example. The regexen are unanchored (and a nice 'eq' makes more sense anyway). ref should be replaced with isa or something from Scalar::Util. And these just point out the limitations with this syntax: Try to fix the code and this syntax will fight you. And then passing the hash to the print function as a big list? ... ]
- tye
|
|---|