for my $sub (@{$Document->find('PPI::Statement::Sub') || []}) { next if $sub->forward; for my $child ($sub->children) { if (ref $child eq "PPI::Structure::Block") { $child->start->add_content("my mars code"); } } }