Skip Menu |

This queue is for tickets about the Switch CPAN distribution.

Report information
The Basics
Id: 18512
Status: resolved
Priority: 0/
Queue: Switch

People
Owner: Nobody in particular
Requestors: mouns [...] mouns.net
petr.chlupaty [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: unbalanced / before switch statement cause fatal error
use Switch; print 1/1; $b = "0"; switch ($b) { case /0/ { print "0\n" } } __END__ without the print 1/1; or with a print 1/1/1; perl execute the code.
Subject: Switch bug - division
Hello! This is a sample code: #!/usr/bin/perl -w use strict; use Switch; my $var = 13/6; #my $var = division(13, 6); sub switchBug{ my $input = shift(); switch( $input ){ case 1 {print "One";} case 2 {print "Two"; } else{print "A lot";} } } sub division{ my $a = shift; my $b = shift; return $a/$b; } When I use division my $var = 13/6; somewhere in the code ABOVE a switch statement, I receive error: Number found where operator expected at ./switch.pl line 10, near "case 1" (Do you need to predeclare case?) Number found where operator expected at ./switch.pl line 11, near "case 2" (Do you need to predeclare case?) syntax error at ./switch.pl line 9, near "){" syntax error at ./switch.pl line 11, near "case 2" Execution of ./switch.pl aborted due to compilation errors. When I comment line with "direct" division or the whole switch statement, it is OK. (I can use division subroutine as shown - when it's defined below a switch statement in the code, it work, but it's ugly...) ================ uname -a Linux coder-4 2.6.15-1-686 #2 Thu Feb 2 18:29:01 UTC 2006 i686 GNU/Linux perl -v This is perl, v5.8.8 built for i486-linux-gnu-thread-multi switch.pm: $VERSION = '2.10_01'; With regards Petr Chlupaty
Subject: Re: [rt.cpan.org #18512] Switch bug - division
Date: Sat, 08 Apr 2006 10:33:47 +1000
To: bug-Switch [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Hi Petr, Inability to corect parse code with divisions in it is a known (and unsolveable) problem with the parser underlying Switch. Sorry. Damian
This will be solved in Switch 2.13, that will be uploaded on CPAN soon. The fix is also available here : http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2007-02/msg00954.html