Subject: | PPI::Token::Quote::Double->interpolations |
Distribution: PPI-1.104 (and looks like PPI-1.108 has the same issues)
Perl version: v5.6.1
OS vendor/version: FreeBSD 4.8-RELEASE-p17
The method PPI::Token::Quote::Double->interpolations is displaying buggy behaviour in that it is reporting strings which do have interpolations to not be. I believe is due to this code in PPI/Token/Quote/Double.pm:
64 sub interpolations {
...
67 # Are there any unescaped $things in the string
68 !! $self->content =~ /(?<!\\)(?:\\\\)*\$/;
69 }
Firstly, the ! operator has a higher precedence than the =~ operator, which means that line 68 is treated by perl as if it was the same as:
(!! $self->content) =~ /(?<!\\)(?:\\\\)*\$/;
This is fixed by putting brackets around the =~ operator and its operands:
!! ($self->content =~ /(?<!\\)(?:\\\\)*\$/);
Secondly, arrays may also be interpolated into strings, eg:
@fruit = qw(apples pears bananas);
print "The fruit are @fruit";
So you also need to check for the @ sigil as well as $. Interpolation also occurs with escape sequence such as \t (tab), \n (newline), \033 (octal), \x1b (hex), \N{name}(named char), as well as a bunch of others.
Regards,
Aaron