1Term::EditorEdit(3)   User Contributed Perl Documentation  Term::EditorEdit(3)
2
3
4

NAME

6       Term::EditorEdit - Edit a document via $EDITOR
7

VERSION

9       version 0.0016
10

SYNOPSIS

12           use Term::EditorEdit;
13
14           # $VISUAL or $EDITOR is invoked
15           $document = Term::EditorEdit->edit( document => <<_END_ );
16           Apple
17           Banana
18           Cherry
19           _END_
20
21       With post-processing:
22
23           $document = Term::EditorEdit->edit( document => $document, process => sub {
24               my $edit = shift;
25               my $document = $edit->document;
26               if ( document_is_invalid() ) {
27                   # The retry method will return out of ->process immediately (via die)
28                   $edit->retry
29               }
30               # Whatever is returned from the processor will be returned via ->edit
31               return $document;
32           } );
33
34       With an "out-of-band" instructional preamble:
35
36           $document = <<_END_
37           # Delete everything but the fruit you like:
38           ---
39           Apple
40           Banana
41           Cherry
42           _END_
43
44           # After the edit, only the text following the first '---' will be returned
45           $content = Term::EditorEdit->edit(
46               separator => '---',
47               document => $document,
48           );
49

DESCRIPTION

51       Term::EditorEdit is a tool for prompting the user to edit a piece of
52       text via $VISUAL or $EDITOR and return the result
53
54       In addition to just editing a document, this module can distinguish
55       between a document preamble and document content, giving you a way to
56       provide "out-of-bound" information to whoever is editing. Once an edit
57       is complete, only the content (whatever was below the preamble) is
58       returned
59

USAGE

61   $result = Term::EditorEdit->edit( ... )
62       Takes the following parameters:
63
64           document            The document to edit (required)
65
66           separator           The string to use as a line separator dividing
67                               content from the preamble
68
69           process             A code reference that will be called once an edit is complete.
70                               Within process, you can check the document, preamble, and content.
71                               You can also have the user retry the edit. Whatever is returned
72                               from the code will be what is returned from the ->edit call
73
74       Returns the edited document (or content if a separator was specified)
75       or the result of the "process" argument (if supplied)
76

SEE ALSO

78       Term::CallEditor
79

AUTHOR

81       Robert Krimen <robertkrimen@gmail.com>
82
84       This software is copyright (c) 2011 by Robert Krimen.
85
86       This is free software; you can redistribute it and/or modify it under
87       the same terms as the Perl 5 programming language system itself.
88
89
90
91perl v5.30.0                      2019-07-26               Term::EditorEdit(3)
Impressum