Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
P is for Practical

Comment on

I have an open PPI document, and I want to insert an assignment statement at a certain point. $lastVar represents the statement after which I want to insert my new line.

I can successfully add a comment with the following:

my $newStatement = PPI::Token::Comment->new(); $newStatement->set_content(qq{\n# $newVar = ${quote}$newValue${quote +};\n}); $lastVar->insert_after($newStatement);
However, I want to add a full statement. If PPI::Statement had a set_content method, this is sort of what I'd like to do:
my $newStatement = PPI::Statement->new(); $newStatement->set_content(qq{\n1; #testing\n});
Can anyone point me in the right direction? Do I need to create a new PPI::Something and the build it up piece by piece from a bunch of other PPI::Something's, or is there a simpler way to add a block of code to a document?


In reply to how to add a PPI:Statement to a document? by blahblahblah

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    As of 2014-03-16 05:34 GMT
    Find Nodes?
      Voting Booth?

      Have you used a cryptocurrency?

      Results (326 votes), past polls