Subject: | Misparsing map followed by regexp containing " |
(sent here from the Perl::Critic bug tracker, rt #75920)
Here's a program that PPI parses wrongly:
map { 0 } /"/
PPI thinks there is a doublequoted string but this is just a regexp
match for the " character.
Here is a more elaborate example demonstrating that perl treats it as a
regexp but PPI does not:
% cat test
use 5.010; $_ = '"""'; @a = map { 0 } /"/g; say "@a";
% perl test
0 0 0
% perl -MPPI -MPPI::Dumper -E 'my $p = new PPI::Document "test"; my $d =
new PPI::Dumper $p; $d->print' PPI::Document PPI::Statement::Include
PPI::Token::Word 'use' PPI::Token::Whitespace ' '
PPI::Token::Number::Float '5.010' PPI::Token::Structure ';'
PPI::Token::Whitespace '\n' PPI::Statement PPI::Token::Magic '$_'
PPI::Token::Whitespace ' ' PPI::Token::Operator '='
PPI::Token::Whitespace ' ' PPI::Token::Quote::Single ''"""''
PPI::Token::Structure ';' PPI::Token::Whitespace '\n' PPI::Statement
PPI::Token::Symbol '@a' PPI::Token::Whitespace ' ' PPI::Token::Operator
'=' PPI::Token::Whitespace ' ' PPI::Token::Word 'map'
PPI::Token::Whitespace ' ' PPI::Structure::Block { ... }
PPI::Token::Whitespace ' ' PPI::Statement PPI::Token::Number '0'
PPI::Token::Whitespace ' ' PPI::Token::Whitespace ' '
PPI::Token::Operator '/' PPI::Token::Quote::Double '"/g;\nsay "'
PPI::Token::Symbol '@a' PPI::Token::Quote::Double '";\n'