Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: alternatives to if and series of elsif

by Xaositect (Friar)
on Jul 01, 2005 at 17:09 UTC ( [id://471775]=note: print w/replies, xml ) Need Help??


in reply to alternatives to if and series of elsif

This may not be relevant to your specific example since you're making two comparisons for each conditional, but there is a perl switch statement on CPAN. More than one actually.


Xaositect - Whitepages.com
  • Comment on Re: alternatives to if and series of elsif

Replies are listed 'Best First'.
Re^2: alternatives to if and series of elsif
by Forsaken (Friar) on Jul 01, 2005 at 20:33 UTC
    And as has been discussed quite often here in the Monastery, actually using Switch.pm is a rather bad idea, as it attempts to parse Perl code and tends to fail in all sorts of unexpected and nasty ways. Switch::Perlish looks nice, but has to jump through a lot of loops in order to emulate switch as we know it from ie C, resulting in what looks like a negligible, if none at all, gain over a regular if/elseif/else construction. From personal experience I'd say either go for the fullblown if/elseif/else construction or, like in this case, use map or a hash.


    Remember rule one...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-04-19 08:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found