PPI::Do...Fragment(3)

πŸ’– PPI::Document::Fragment(3) πŸ’–

okay bestie, so this is the manual for PPI::Document::Fragment from the PPI crew β€” and it's literally just here to let you vibe with a piece of a Perl document instead of the whole entire thing. no cap.


✨ NAME ✨

PPI::Document::Fragment β€” a fragment of a Perl Document. that's it, that's the whole name, she's simple and she knows it πŸŽ€


🌸 DESCRIPTION 🌸

so here's the tea, bestie: sometimes you're out here and you only wanna work with a fragment of a bigger document. like, not the whole doc, just a lil chunk of it. and PPI::Document::Fragment is the class made for exactly that.

it's functionally almost identical to a normal PPI::Document β€” like, same energy, same vibe β€” EXCEPT for two very important things:

  • it is not possible to get line/column positions for the elements within it 😭
  • it does not represent a scope

so yeah. basically a PPI::Document that doesn't know where it is and doesn't hold space for a scope. she's a fragment, not a whole meal πŸ’…


πŸ¦‹ METHODS πŸ¦‹

🌈 index_locations

so when you call this on a regular PPI::Document object, it does the whole location-indexing thing. but on a PPI::Document::Fragment? bestie, you should not be trying to find locations of things in there in the first place.

and because of that, any call to index_locations will:

  • print a warning ⚠️
  • return undef

instead of even attempting to index the locations of the Elements. it's not being dramatic, it's just being honest about what it can't do 🫢


πŸ‘‘ TO DO πŸ‘‘

the actual plans, fr fr: integrate this into the rest of PPI so it has actual practical uses. because rn? it's giving untapped potential.

and the most obvious glow-up would be to implement arbitrary cut/copy/paste more easily. imagine the clipboard drama we could avoid. iconic behaviour, honestly. πŸ”₯


🧚 SUPPORT 🧚

head over and see the support section in the main module. iykyk πŸ’œ


πŸ’« AUTHOR πŸ’«

Adam Kennedy <adamk@cpan.org> β€” legend, icon, the moment. πŸ‘‘


Copyright 2001 - 2011 Adam Kennedy.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module. πŸ“œ


and that's the whole page, bestie!! πŸŽ€ this was documented in perl v5.42.0, dated 2026-01-17, and it's the PPI::Do...Fragment(3) page β€” now go forth and fragment responsibly πŸ’–βœ¨

πŸ“¦ where this page comes from