in reply to Re^5: fall through switch/case in perl
in thread fall through switch/case in perl
Hmm. I think what your saying is that the eval is necessary to avoid a warning if $var doesn't contain a value for which there is a label defined?No, I'm saying that goto $label dies if the label has not been defined. That is not how it works in C. In C, if you have not provided a case that matches your switch value, it jumps to the default case. That's why there's an eval, to prevent the die (not warning).
As far as preventing a warning on undef, well... I'd imagine that that should fit into whatever scheme you are using around undefs: warn if you have undef warnings on, else not. And there's nothing about stringifying $var that changes that semantic, so all seems well and good with my method.[sstone@granite sstone]$ perl -le 'print 1; goto "FOO"; print 2' 1 Can't find label FOO at -e line 1. [sstone@granite sstone]$
------------ :Wq Not an editor command: Wq
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: fall through switch/case in perl
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 etcshadow (Priest) on Sep 07, 2004 at 19:11 UTC | |
by BrowserUk (Patriarch) on Sep 07, 2004 at 19:22 UTC | |
| |
|
Re^7: ** fall through switch/case in perl
by Anonymous Monk on Sep 07, 2004 at 08:43 UTC | |
by Beechbone (Friar) on Sep 08, 2004 at 13:59 UTC |