Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

using switch

by sicone (Initiate)
on Sep 29, 2005 at 12:56 UTC ( #496084=perlquestion: print w/replies, xml ) Need Help??

sicone has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: using switch
by castaway (Parson) on Sep 29, 2005 at 13:04 UTC
Re: using switch
by Corion (Patriarch) on Sep 29, 2005 at 13:05 UTC
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: using switch
by Roy Johnson (Monsignor) on Sep 29, 2005 at 13:55 UTC
    There are a couple of alternatives to the Switch module, which don't share its weakness of being source-filtered. See Switch::Perlish and (my own) Case.

    Caution: Contents may have been coded under pressure.
Re: using switch
by thundergnat (Deacon) on Sep 29, 2005 at 13:29 UTC

    Your best bet is to avoid using Switch at all, especially in production code. It is very easy to introduce very hard to trace bugs and is just too fragile.

    If you have a large number of possible branches use a dispatch table, otherwise, if-then-else (or ? : ).

Re: using switch
by Limbic~Region (Chancellor) on Sep 29, 2005 at 13:38 UTC
    sicone,
    As has been pointed out, using Switch in production code is discouraged. This will be mostly remedied in Perl6. Dispatch Tables don't offer the same degree of flexibility, but for specific problems are a great solution.

    Cheers - L~R

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://496084]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2023-06-07 00:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (29 votes). Check out past polls.

    Notices?