PPI对Perl的Heredoc的不正确标记

我正在使用PPI来对Perl文件进行标记。但是,heredoc似乎没有正确标记。我正在使用以下代码对文件进行标记:

while True:
  result = func()
  if not (results.append(result)):
     break

以下是被标记化的perl文件:

my $file_name = shift @ARGV;

use PPI;
use PPI::Dumper;

my $Document = PPI::Document->new($file_name);

my $Dumper = PPI::Dumper->new($Document);

$Dumper->print;

__END__

我得到以下输出:

my $name = 'Foo';

my $message = <<'END_MESSAGE';
Dear $name,this is a message I plan to send to you.

regards
  the Perl Maven
END_MESSAGE

print $message;

有什么办法可以获取整个Heredoc的值吗?

kk771396 回答:PPI对Perl的Heredoc的不正确标记

根据documentation,此处文档的内容可通过heredoc方法使用:

my $Document = PPI::Document->new($file_name);
my @heredoc = $Document->find_first('PPI::Token::HereDoc')->heredoc;
say join "",@heredoc;

输出

Dear $name,this is a message I plan to send to you.

regards
  the Perl Maven
本文链接:https://www.f2er.com/3075925.html

大家都在问