in reply to Re: Semantic diff for Perl code

Have you tried sticking the ::Sub into a new PPI::Document or PPI::Document::Fragment and saving that?

Replies are listed 'Best First'.
Re^3: Semantic diff for Perl code
by clueless newbie (Curate) on Sep 27, 2017 at 19:17 UTC

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

      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.