After changing the contents of a PPI::Token::QuoteLike::Words element with the set_contents method, it seems that the changed contents is not reparsed and internal meta-data not updated. This leads to a call to literal returning wrong results.
The below MWE program
#!/usr/bin/env perl
use v5.24;
use strict;
use warnings;
use Data::Dumper;
use PPI;
my $doc = PPI::Document->new(\q!my @a = qw( 1 2 3);!);
my $qw = $doc->find_first('PPI::Token::QuoteLike::Words');
print Dumper([ $qw->literal ], $qw);
$qw->set_content($qw->content =~ s/ 2//r);
print Dumper([ $qw->literal ], $qw);
first returns the tokens 1,2,3 as expected, but the second time returns 1 and 3).
After changing the contents of a
PPI::Token::QuoteLike::Words
element with theset_contents
method, it seems that the changed contents is not reparsed and internal meta-data not updated. This leads to a call toliteral
returning wrong results.The below MWE program
first returns the tokens 1,2,3 as expected, but the second time returns
1
and3)
.