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...