develooper Front page | perl.perl5.porters | Postings from April 2008

RE: [perl #53414] Parse problem in Switch.pm

Thread Next
From:
David Freedman
Date:
April 27, 2008 11:55
Subject:
RE: [perl #53414] Parse problem in Switch.pm
Message ID:
FFBEC1DE79841C4C965378BBDA5913FC4CD6EB@EXVS01.claranet.local
Ok, I thought it was part of the distribution when I installed it, I didn't get it from cpan , it came with my perl distribution.

Many thanks for your response.



------------------------------------------------
David Freedman
Group Network Engineering 
Claranet Limited
http://www.clara.net



-----Original Message-----
From: Bram via RT [mailto:perlbug-followup@perl.org]
Sent: Sun 4/27/2008 15:25
To: David Freedman
Subject: [perl #53414] Parse problem in Switch.pm 
 
> -----------------------------------------------------------------
> 
> Switch.pm seems to have a parse problem.
> 
> The following test case illustrates this:
> 
> perl -MSwitch -e '$foo = (1/2); switch($s) { case /foo/ { print } }'
> 
> If you change the divide operation to another type of operation (+ for
>    instance) the problem no longer manifests,
> also, if you change the case from pattern matching to another type of
>    matching the problem no longer manifests.
> 
> The source parser being used in Switch seems to hook on the divisor
>    operator which is outside of its scope.
> 
> This seems to have been present in Switch.pm for some time.
> 
> -----------------------------------------------------------------

Hello,


First of all thank you for your bug report.

Second, the Switch module is not part of the perl CORE but is a 
separtae module that lives on CPAN.

It would be best to fill the bug report on the queue of the switch 
module ( http://rt.cpan.org/Public/Dist/Display.html?Name=Switch ).


The syntax error happens because Switch uses source filters which 
rewrite the source... But source filters are limited in what they can 
do correctly and will break correct code sooner or later.

Also of intrest: in perl v5.10 a native 'switch' called given/when was 
added ( http://perldoc.perl.org/perlsyn.html#Switch-statements ).

Kind regards,

Bram



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About