PPI
PPI copied to clipboard
Misparse of qw with comment before first delimiter
perldoc -f qw explains that if qw is followed by whitespace plus '#', the rest of the line is a comment, and the qw's opening delimiter will be taken from the following line:
There can be whitespace between the operator and the quoting characters,
except when "#" is being used as the quoting character. "q#foo#" is parsed
as the string "foo", while "q #foo#" is the operator "q" followed by a
comment. Its argument will be taken from the next line. This allows you to
write:
s {foo} # Replace foo
{bar} # with bar.
With test file:
$ cat test.pl
print join ",", qw # comment
( a )
perl acts as documented:
perl -W test.pl
a
whereas PPI does not:
$ perl -MPPI::Document -WE 'say join( ",", PPI::Document->new("test.pl")->schild(0)->schild(4)->literal )'
(,a,)
I really thought I had caught all of the qw special cases... darn.