in reply to how to add a PPI:Statement to a document?

Watch carefully
$Document = PPI::Document->new(\'print "Hello World!\n"'); $lastVar->insert_after( $Document );

Replies are listed 'Best First'.
Re^2: how to add a PPI:Statement to a document?
by Anonymous Monk on Jan 02, 2008 at 07:20 UTC
    $Document = PPI::Document->new(\'print "Hello World!\n"'); $lastVar->insert_after( $Document->find_first('Statement') );
    A little more verbose, but much clearer in intent.
      In fact, you also should just throw away the other document immediately.
      $lastVar->insert_after( PPI::Document->new('print "Hello World!\n")->f +ind_first('Statement') );