Term::EditorEdit(3)
π NAME π
Term::EditorEdit β bestie, it edits a document via $EDITOR β¨
πΈ VERSION πΈ
version 0.0016 β she's serving, she's stable, she's iconic π
π¦ SYNOPSIS π¦
okay so like, the basics:
use Term::EditorEdit;
# $VISUAL or $EDITOR is invoked
$document = Term::EditorEdit->edit( document => <<_END_ );
Apple
Banana
Cherry
_END_
and then when you wanna do a little post-processing (main character behaviour honestly):
$document = Term::EditorEdit->edit( document => $document, process => sub {
my $edit = shift;
my $document = $edit->document;
if ( document_is_invalid() ) {
# The retry method will return out of ->process immediately (via die)
$edit->retry
}
# Whatever is returned from the processor will be returned via ->edit
return $document;
} );
and now the β¨fancyβ¨ one β with an "out-of-band" instructional preamble, no cap:
$document = <<_END_
# Delete everything but the fruit you like:
---
Apple
Banana
Cherry
_END_
# After the edit, only the text following the first '---' will be returned
$content = Term::EditorEdit->edit(
separator => '---',
document => $document,
);
π DESCRIPTION π
Term::EditorEdit is literally a tool for prompting the user to edit a piece of text via $VISUAL or $EDITOR and return the result π«Ά
And listen β it's not just editing a document. This module can distinguish between a document preamble and document content, which gives you a way to hand "out-of-bound" information to whoever is editing. Once an edit is complete, only the content (whatever was below the preamble) is returned. it's giving β¨separation of concernsβ¨
π USAGE π
$result = Term::EditorEdit->edit( ... )
Takes the following parameters, bestie, write these down π
documentβ the document to edit (required, like actually required, she will not function without it)separatorβ the string to use as a line separator dividing content from the preambleprocessβ a code reference that will be called once an edit is complete. Within process, you can check the document, preamble, and content. You can also have the user retry the edit. Whatever is returned from the code will be what is returned from the->editcall
Returns the edited document (or content if a separator was specified) or the result of the process argument (if supplied) π
π SEE ALSO π
- Term::CallEditor β the sibling, the family, the lineage π
β AUTHOR β
Robert Krimen <robertkrimen@gmail.com> β legend behaviour honestly π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2011 by Robert Krimen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt π
and that's the whole page bestie!! β¨ this was perl v5.42.0, dated 2025-07-25, and it lives at Term::EditorEdit(3) β go forth and edit your little heart out, ily π«Άππ
π¦ where this page comes from
- fedora 43: perl-Term-EditorEdit 0.0016-33.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms