in reply to Re^6: fall through switch/case in perl
in thread fall through switch/case in perl
Fair enough, but in TimToady's original, he had 'CASE'.($var+0) which avoids dieing.
P:\test>perl -le" print 1; $var = 'foo'; goto 'CASE'.($var+0); CASE0: +print 2;" 1 2
And that allows CASE0: to become the default.
The only situation this doesn't cover is when $var is undef'd; but then none of the other solutions handle that (except the do{ local $^W; $var + 0 }; I suggested).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: fall through switch/case in perl
by etcshadow (Priest) on Sep 07, 2004 at 06:34 UTC | |
by BrowserUk (Patriarch) on Sep 07, 2004 at 06:53 UTC | |
by etcshadow (Priest) on Sep 07, 2004 at 19:11 UTC | |
by BrowserUk (Patriarch) on Sep 07, 2004 at 19:22 UTC | |
by etcshadow (Priest) on Sep 07, 2004 at 21:40 UTC |