Skip Menu |

This queue is for tickets about the Switch CPAN distribution.

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

Owner: Nobody in particular
Requestors: mouns [...]
petr.chlupaty [...]

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

Subject: unbalanced / before switch statement cause fatal error
Download (untitled) / with headers
text/plain 399b
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
Download (untitled) / with headers
text/plain 1.2k
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 ./ line 10, near "case 1" (Do you need to predeclare case?) Number found where operator expected at ./ line 11, near "case 2" (Do you need to predeclare case?) syntax error at ./ line 9, near "){" syntax error at ./ line 11, near "case 2" Execution of ./ 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 $VERSION = '2.10_01'; With regards Petr Chlupaty
Subject: Re: [ #18512] Switch bug - division
Date: Sat, 08 Apr 2006 10:33:47 +1000
To: bug-Switch [...]
From: Damian Conway <damian [...]>
Download (untitled) / with headers
text/plain 150b
Hi Petr, Inability to corect parse code with divisions in it is a known (and unsolveable) problem with the parser underlying Switch. Sorry. Damian
Download (untitled) / with headers
text/plain 183b
This will be solved in Switch 2.13, that will be uploaded on CPAN soon. The fix is also available here :

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to