Re: Problem with Switch.pm

"$Bill Luebkert" <[email protected]> Thu, 17 Jan 2013 11:39:04 -0800
Newsgroups gmane.comp.lang.perl.active-perl
Message-ID <[email protected]>
On 1/17/2013 06:26, Rothenmaier, Deane wrote:
> Gurus,
>
> I=92m having a problem getting Switch to work. I have a subroutine which =
is just a large switch statement, and switch statements (including a nested=
 one) in the mainline code. As separate programs (with the subroutine broke=
n out into a stub program), they both work perfectly. When I put the switch=
 version of the sub back into the program code, the thing breaks with the m=
essage: =93Bad switch statement (problem in the code block?) near test.pl l=
ine 4294.=94  I should mention that line 4294 is the last line of the sourc=
e file; so no help there.

You've been around long enough to know you need to supply a
'standalone', 'compilable' snippet of code for us to try.  I
added a few vrbl defs and it compiled OK for me, but obviously
it does nothing in my case since there is no data to mash.

I would add parens on all case values just to make sure I wasn't
breaking any syntax rules and make it look uniform - eg: removing
the () from
	case ($check_col) {
creates a similar error so I'd always use them.  I'd be a little
worried about undefined switches and undefined case values too -
not sure what happens past an undefined switch vrbl would match an
undefined case value.

[perl v5.12.4]

Added:

use strict;
use warnings;
use Switch;

my $key;
my $check_col;
my $col_ndx;
my %sw_data;
my $col_data;
my $data_line;

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs