> Could a way be found to control the flow so that the next case (not always
> the one next in the order of the statment) could be executed? For example
> you have cases 1-10. You want all odd cases to also execute case 9 and the
> even cases to also execute case 10. So in case 3 you would say something
> like: pergo(9);
Not necessary.
switch ($val) {
case 3 { print "three"; goto odds }
case 4 { print "three"; goto evens }
odds: case __%2!=0 { print "that's odd" }
evens: case __%2==0 { print "that's even" }
}
Or for those who hate pasta:
sub odds { print "that's odd" }
sub evens { print "that's even" }
switch ($val) {
case 3 { print "three"; odds }
case 4 { print "three"; evens }
case __%2!=0 { odds }
case __%2==0 { evens }
}
Damian
- Re: RFC 22 (v1) Builtin switch statem... Jeremy Howard
- Re: RFC 22 (v1) Builtin switch statem... Ken Fox
- Re: RFC 22 (v1) Builtin switch statem... Damian Conway
- Re: RFC 22 (v1) Builtin switch s... Jarkko Hietaniemi
- Re: RFC 22 (v1) Builtin swit... Chaim Frenkel
- Re: RFC 22 (v1) Builtin switch s... Chaim Frenkel
- Re: RFC 22 (v1) Builtin switch statement Damian Conway
- ConwayPerl (was Re: RFC 22 (v1) Builtin switc... Jeremy Howard
- Re: RFC 22 (v1) Builtin switch statement Bart Lateur
- RE: RFC 22 (v1) Builtin switch statement Lipscomb, Al
- Re: RFC 22 (v1) Builtin switch statement Damian Conway
- Re: RFC 22 (v1) Builtin switch statement Jonathan Scott Duff
- Re: RFC 22 (v1) Builtin switch statement Glenn Linderman
- Re: RFC 22 (v1) Builtin switch statement Damian Conway
- RE: RFC 22 (v1) Builtin switch statement Lipscomb, Al
