in reply to Re: Syntax error with use constant and switch with comment between
in thread Syntax error with use constant and switch with comment between

Thanks for looking into the version differences. I will take your advice and avoid Switch. I am proposing (to nonbelievers I work with) to use perl as a replacement for what is currently a custom sub-configuration file with logical selections based on settings in a top-level config file. The switch statement would be more familiar and therefore more likely to be favorably received (than if-elsif-elsif-elsif...else). In any case, I will request a company wide update to 5.10 before I propose the config file change. I trust that the given-when construct is a different animal inside than switch-case.

I also plan to get Readonly installed to replace use constant as suggested by Conway's PBP book, unless...

Also, thanks to the other monk who provided background on how Switch is implemented under the covers. I am not a fan of source filters.

  • Comment on Re^2: Syntax error with use constant and switch with comment between
  • Download Code

Replies are listed 'Best First'.
Re^3: Syntax error with use constant and switch with comment between
by ikegami (Patriarch) on Dec 07, 2009 at 04:51 UTC

    I propose the config file change. I trust that the given-when construct is a different animal inside than switch-case.

    It is a switch statement

    given ($convention) { when ('E') { print "east longitude $long radians\n"; } when ('W') { $long = TWOPI-$long; print "west longitude $long radians\n"; } default { print "error: $convention not valid\n"; } }

    But it doesn't have to do its own Perl parsing like Switch because it's a builtin control statement like for and while.