PPI
PPI copied to clipboard
Line numbers not working after clone
use PPI;
use PPI::Find;
my $src = q{f($x, $z, $x);};
my $doc = PPI::Document->new(\$src);
my $finder = PPI::Find->new( sub {
$_[0]->isa('PPI::Statement');
});
$finder->start($doc);
while ( my $token = $finder->match ) {
#print "lineA ", $token->line_number, $token->column_number, "\n";
my $t = $token->clone;
print "lineB ", $t->line_number, $t->column_number, "\n";
}
prints
lineB
lineB
but if I uncomment "lineA" print:
lineA 11
lineB 11
lineA 13
lineB 13