Help language development. Donate to The Perl Foundation

Proc::Editor cpan:JKRAMER last updated on 2018-04-25
[![Build Status](](


Proc::Editor - Start a text editor


    use Proc::Editor;

    my $text = edit('original text');
    say "Edited text: {$text.trim}";


Proc::Editor runs a text editor and returns the edited text.



This is merely a shortcut for convenience, all arguments are passed on to ``.



Create a new instance of `Proc::Editor`. `:editors` may be used to override the default list of editors to try. By default, the environment variables $VISUAL and $EDITOR are checked, then it tries /usr/bin/vi, /bin/vi and /bin/ed (in that order).

`edit(Str $text?, IO::Path :$file, Bool :$keep)`

Writes `$text` to a temporary file runs an editor with that file as argument. On success, the contents of the file are returned. If `$file` is defined, it is used instead of creating a temporary file. The file used (temporary or not) are deleted afterwards unless `:keep` is provided.

`edit-file(IO::Path $path)`

Starts an editor with the given `$path` as argument. Returns the editors exit-code on success (which should always be 0) or dies on error.


Jonas Kramer <[email protected]>


Copyright 2018 Jonas Kramer

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.