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

Re: [perl #53414] perlbug AutoReply: Parse problem in

Thread Previous
David Landgren
April 28, 2008 13:43
Re: [perl #53414] perlbug AutoReply: Parse problem in
Message ID:
David Freedman wrote:
> Also, reading the module POD, it seems the author was aware of certain conflicts with the divisor operator
> , he states:
> "Due to the heuristic nature of's source parsing, the presence of
> regexes with embedded newlines that are specified with raw C</.../>
> delimiters and don't have a modifier C<//x> are indistinguishable from
> code chunks beginning with the division operator C</>. As a workaround
> you must use C<m/.../> or C<m?...?> for such patterns. Also, the presence
> of regexes specified with raw C<?...?> delimiters may cause mysterious
> errors. The workaround is to use C<m?...?> instead."
> However, my example does not use embedded newlines, also, the following examples fail:
> perl -MSwitch -e '$foo = (1/2); switch($s) { case m/foo/ { print } }'
> perl -MSwitch -e '$foo = (1/2); switch($s) { case m/foo/i { print } }'
> perl -MSwitch -e '$foo = (1/2); switch($s) { case /foo/i { print } }'
> Not sure if this is so much a bug , but a limitation of the module which is not 
> documented properly, either way, is a module which behaves like this suitable for the core?

Well, you could always

perl -MSwitch -e '$foo = (1*0.5); switch($s) { case /foo/i {print} }'

but you are probably better off putting Switch down on the floor and 
walking away very slowly without making any sudden movements. Even the 
author recommends not using this module in production:

since its "purpose is to explore and prototype future core language 
features". And in fact, that's exactly what happened in 5.10, where a 
native switch construct was added to the language.

Thanks for your report,
David Landgren

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About