On 1/17/2013 06:26, Rothenmaier, Deane wrote:
> Gurus,
>
> I’m 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 broken 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 message: 
> “Bad switch statement (problem in the code block?) near test.pl line 4294.”  
> I should mention that line 4294 is the last line of the source 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
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to