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

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

Thread Previous | Thread Next
From:
H.Merijn Brand
Date:
April 27, 2008 09:05
Subject:
Re: [perl #53414] Parse problem in Switch.pm
Message ID:
20080427180525.074f6cc4@pc09.procura.nl
On Sun, 27 Apr 2008 07:25:57 -0700, "Bram via RT"
<perlbug-followup@perl.org> wrote:

> > Switch.pm seems to have a parse problem.

Yes, several.

> > 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.

Switch also cannot cope well with the defined-or operator //

> > 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.

Actually, it is dual-lived, and part of the CORE since 5.7.3

$ corelist -a Switch

Switch was first released with perl 5.007003
  5.007003   2.06
  5.008      2.09
  5.008001   2.10
  5.008002   2.10
  5.008003   2.10
  5.008004   2.10
  5.008005   2.10
  5.008006   2.10
  5.008007   2.10
  5.008008   2.10_01
  5.009      2.10
  5.009001   2.10
  5.009002   2.10
  5.009003   2.10_01
  5.009004   2.10_01
  5.009005   2.13
  5.01       2.13

> 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 ).

-- 
H.Merijn Brand         Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using & porting perl 5.6.2, 5.8.x, 5.10.x  on HP-UX 10.20, 11.00, 11.11,
& 11.23, SuSE 10.1 & 10.2, AIX 5.2, and Cygwin.       http://qa.perl.org
http://mirrors.develooper.com/hpux/            http://www.test-smoke.org
                        http://www.goldmark.org/jeff/stupid-disclaimers/

Thread Previous | 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