in reply to Re^3: fall through switch/case in perl
in thread fall through switch/case in perl
Which, admittedly, is not very different from Aristotle's. The only real difference being the outter braces. The purpose of them is to avoid polluting the label name-space. (Also, I prefer the "goto X or goto DEFAULT" over the "goto X; goto DEFAULT" purely for aesthetic reasons. :-D){ eval { goto "CASE$var" } or goto DEFAULT; CASE10: print "a"; CASE9: print "b"; CASE8: print "c"; CASE7: print "d"; CASE6: print "e"; CASE5: print "f"; CASE4: print "g"; CASE3: print "h"; CASE2: print "i"; CASE1: print "j"; DEFAULT: }
I sort of wonder why this isn't given as one of the ways of achieving C-like switch statement behavior in the perl docs? Oh, well... it's probably horribly inefficient or something (apart from just being too C-ish or something).
------------ :Wq Not an editor command: Wq
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: fall through switch/case in perl
by BrowserUk (Patriarch) on Sep 07, 2004 at 04:10 UTC | |
by etcshadow (Priest) on Sep 07, 2004 at 05:44 UTC | |
by BrowserUk (Patriarch) on Sep 07, 2004 at 05:57 UTC | |
by etcshadow (Priest) on Sep 07, 2004 at 06:34 UTC | |
by BrowserUk (Patriarch) on Sep 07, 2004 at 06:53 UTC | |
| |
by Anonymous Monk on Sep 07, 2004 at 08:43 UTC | |
by Beechbone (Friar) on Sep 08, 2004 at 13:59 UTC |