Term::EditorEdit(3)

πŸ“¦
version 0.0016 Β· 2 versions
, in fedora 43

πŸ’– 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 preamble
  • process β€” 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 ->edit call

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 πŸ™Œ


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