http://www.perlmonks.org?node_id=1078453


in reply to Given When Syntax

use feature 'switch';

:-)

Replies are listed 'Best First'.
Re^2: Given When Syntax
by Deep_Plaid (Acolyte) on Mar 15, 2014 at 16:12 UTC

    Hi HazyLife. I did consider using the Switch module, but I had read that it is being deprecated and that I should be using given/when, and that is is more efficient. No other reason I can't or won't - I was just curious why I'm getting the syntax errors for given/when. Also, this is a part of a much larger script that has a long processing time and I'm trying to be as efficient as possible. Thanks for your input!

      re hazylife's observation, you need to understand that...
            use feature "switch";" is NOT EQUAL to use Switch;.


      Questions containing the words "doesn't work" (or their moral equivalent) will usually get a downvote from me unless accompanied by:
      1. code
      2. verbatim error and/or warning messages
      3. a coherent explanation of what "doesn't work actually means.
        True, but the switch and smartmatching features (given+when and ~~) are also experimental and likely to change.