in reply to Re^2: fall through switch/case in perl
in thread fall through switch/case in perl
The eval isn't required (unless I missed a subtlety?)
#! perl -sw use strict; my $var = 7; goto 'CASE'.($var+0); die "$var out of range"; 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"; print "\n"; __END__ P:\test>junk defghij
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: fall through switch/case in perl
by etcshadow (Priest) on Sep 07, 2004 at 02:52 UTC | |
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 Anonymous Monk on Sep 07, 2004 at 08:43 UTC | |
by Beechbone (Friar) on Sep 08, 2004 at 13:59 UTC |