PPI::Do...nt::File(3)

✨ PPI::Document::File ✨

okay bestie, so this is the manual page for PPI::Document::File β€” that's part of the PPI::Do...nt::File(3) manual, section 3 of the Perl docs, and it's giving very specific-file energy πŸ’…


🌸 NAME 🌸

PPI::Document::File β€” a Perl Document that lives in one specific file πŸ—‚οΈβœ¨


πŸ¦‹ DESCRIPTION πŸ¦‹

WARNING: this class is experimental, and it may change without notice. fr fr, no cap β€” do not build your whole personality on it staying the same 😭

PPI::Document::File hands you a PPI::Document subclass that represents a Perl document stored in a specific named file. like, it's not just a document, it's a document that knows which file it came from. main character with a home address πŸ‘‘


πŸŽ€ METHODS πŸŽ€

πŸ’– new

my $file = PPI::Document::File->new( 'Module.pm' );

so the new constructor works exactly the same as the regular one, except β€” and this is the whole vibe β€” the only param allowed is a file name. that's it. that's the list.

you literally cannot create an "anonymous" PPI::Document::File object, and you cannot create an empty one either. no file, no object, periodt πŸ™…β€β™€οΈ

it returns a shiny new PPI::Document::File object, or undef if something went wrong πŸ’€


🌈 save

# Save to the file we were loaded from
$file->save;

# Save a copy to somewhere else
$file->save( 'Module2.pm' );

the save method works similarly to the one in the parent PPI::Document class β€” it saves a copy of the document to a file. same energy, mostly 🫢

but here's the difference with this subclass: if save is not passed any filename, it will save it right back to the file it was loaded from. it remembers where it came from. iconic, honestly ✨

Note: when you save to a different file, that's considered saving a copy. so the value returned by the filename accessor will stay the same and will not change to the new filename. the object's home file does not move, bestie 🏠

⭐ TO DO ⭐

  • May need to overload some methods to forcefully prevent Document objects becoming children of another Node. (yes it's on the list, no it's not done yet πŸ™ˆ)

πŸ’œ SUPPORT πŸ’œ

see the support section in the main module 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Adam Kennedy <adamk@cpan.org>


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 one came from perl v5.42.0, dated 2026-01-17, filed under PPI::Do...nt::File(3) in the User Contributed Perl Documentation. go forth and slay your file-based documents πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from