Perl-Sensitive Sunglasses | |
PerlMonks |
Re: switch stattementby leighsharpe (Monk) |
on Aug 04, 2009 at 03:21 UTC ( [id://785630]=note: print w/replies, xml ) | Need Help?? |
You're going to be told repeatedly that "In perl, there's more than one way to do it.". And, there is more than one way to do what you want. Are you using strict and warnings in your example? The first thing that jumps out at me is that you may have a problem with scoping. If you have a Before your switch statement, the results may be somewhat different to what you are seeing. (by the way, just what is it doing?) You may also want to consider using a hash, if you don't have too many options:
Another option is to use something like this: etc. etc. Or, as already mentioned, use Switch. etc. etc. As a final note, if you're using 5.10, there's always the builtin given/when.
In Section
Seekers of Perl Wisdom
|
|