in reply to Re^2: Semantic diff for Perl code
in thread Re: Semantic diff for Perl code

I'm uncertain as to how one inserts "$sub" into the new PPI::Document or PPI::Document::Fragment.

Replies are listed 'Best First'.
Re^4: Semantic diff for Perl code
by Anonymous Monk on Sep 27, 2017 at 19:33 UTC
    untested, but try
    my $subdoc = PPI::Document::Fragment->new(\$sub->content); write_to_file($subdoc->serialize(), ...);
      This loses the content of the heredoc. Instead of
      sub Fee { return <<__Fee__; Fee __Fee__ }

      one gets

      sub Fee { return <<__Fee__; }

      Apparently except when the object is a PPI::Token::Heredoc the content method's return doesn't include the contents of any PPI::Token::Heredoc.