Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Nested Switch case

by CheeseConQueso (Initiate)
on Nov 29, 2010 at 15:17 UTC ( [id://874266]=note: print w/replies, xml ) Need Help??


in reply to Re: Nested Switch case
in thread Nested Switch case

Why do you suggest keeping away from Switch? Just curious because I use it in a couple scripts...

Replies are listed 'Best First'.
Re^3: Nested Switch case
by cdarke (Prior) on Nov 29, 2010 at 15:46 UTC
    Switch uses source filters, which are generally considered a poor and buggy solution. To quote from the perl 5.10.1 perldelta:

    Switch is buggy and should be avoided. From perl 5.11.0 onwards, it is intended that any use of the core version of this module will emit a warning, and that the module will eventually be removed from the core (probably in perl 5.14.0). See Switch statements in the perlsyn manpage for its replacement.
Re^3: Nested Switch case
by roboticus (Chancellor) on Nov 29, 2010 at 16:51 UTC

    CheeseConQueso:

    Primarily because it's a source filter: In other words, it rewrites your code before the parser can parse it. So it'll probably work perfectly nearly all of the time. But if it gets confused, the parser is going to report problems on the rewritten code, rather than the code you're working on. So the line numbers and/or descriptions of the errors may have little bearing on the source code you're working on. Additionally, if the module gets confused, it may alter code not related to any switches. This can be confusing, since you probably won't suspect Switch to be the cause of a problem where there are no switch statements near the reported problems.

    ...roboticus

Re^3: Nested Switch case
by Fletch (Bishop) on Nov 29, 2010 at 21:58 UTC

    Not to mention the author consider(ed|s) it "experimental" and not for production use.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re^3: Nested Switch case
by amir_e_a (Hermit) on Nov 29, 2010 at 22:29 UTC

    I used the Switch module around 2006 in a program of a few thousands of lines that was supposed to be used in a production environment. It caused some surprising bugs. I don't even remember what they were exactly, but it really wasn't something that i would expect to come from using such a module. It didn't save me any typing and didn't add any elegance to the code, and i wasted some time (an hour maybe) trying to understand what causes the bugs until i just replaced it with if/else and didn't look back.

    given/when is great if you can use it, though.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-25 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found