Term::EditorEdit(3pm)

Term::EditorEdit3pm

Edit a document via $editor

Usage

    use Term::EditorEdit;
    
    # $VISUAL or $EDITOR is invoked
    $document = Term::EditorEdit->edit( document => <<_END_ );
    Apple
    Banana
    Cherry
    _END_

With post-processing:

    $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;
    } );

With an "out-of-band" instructional preamble:

    $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,
    );

Version

version 0.0016

Overview

Term::EditorEdit is a tool for prompting the user to edit a piece of text via $VISUAL or $EDITOR and return the result

In addition to just editing a document, this module can distinguish between a document preamble and document content, giving you a way to provide "out-of-bound" information to whoever is editing. Once an edit is complete, only the content (whatever was below the preamble) is returned

Usage

$result = Term::EditorEdit->edit( ... )

Takes the following parameters:

    document            The document to edit (required)
    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)

Releases

3 releases since Debian 8 (Jessie); the text changed 1 time.

  1. 8
  2. 9–10

Author

Robert Krimen <[email protected]>

From libterm-editoredit-perl 0.16-2 in Debian 10 (Buster). Parsed by carta from the page's man source.