PPI::Statement::Variable not detected inside an open() call without parenthesis
omerisimo opened this issue · 0 comments
omerisimo commented
When parsing an open my $fh ...
function without parenthesis, PPI does not identify the $fh
as a variable (PPI::Statement::Variable
) but as a symbol instead (PPI::Token::Symbol
).
Example:
use strict;
use warnings;
use PPI::Dumper;
use PPI::Document;
print "call open() with parenthesis\n";
my $doc_good = PPI::Document->new(\'open(my $foo, "<", "/etc/motd");');
PPI::Dumper->new($doc_good)->print;
print "call open() with NO parenthesis\n";
my $doc_bad= PPI::Document->new(\'open my $foo, "<", "/etc/motd";');
PPI::Dumper->new($doc_bad)->print;
Output:
call open() with parenthesis
PPI::Document
PPI::Statement
PPI::Token::Word 'open'
PPI::Structure::List ( ... )
PPI::Statement::Variable
PPI::Token::Word 'my'
PPI::Token::Whitespace ' '
PPI::Token::Symbol '$foo'
PPI::Token::Operator ','
PPI::Token::Whitespace ' '
PPI::Token::Quote::Double '"<"'
PPI::Token::Operator ','
PPI::Token::Whitespace ' '
PPI::Token::Quote::Double '"/etc/motd"'
PPI::Token::Structure ';'
call open() with NO parenthesis
PPI::Document
PPI::Statement
PPI::Token::Word 'open'
PPI::Token::Whitespace ' '
PPI::Token::Word 'my'
PPI::Token::Whitespace ' '
PPI::Token::Symbol '$foo'
PPI::Token::Operator ','
PPI::Token::Whitespace ' '
PPI::Token::Quote::Double '"<"'
PPI::Token::Operator ','
PPI::Token::Whitespace ' '
PPI::Token::Quote::Double '"/etc/motd"'
PPI::Token::Structure ';'