App::bif::Editor - run a system (text) editor


0.1.5_8 (yyyy-mm-dd)


use App::bif::Editor;

my $editor = App::bif::Editor->new(txt => $some_text);

print "You edited the following:\n". $editor->result;


App::bif::Editor starts a system editor, optionally with text that you provide, or on a filename you provide, and allows you to retrieve the result.

This does basically the same thing as Proc::InvokeEditor, however it has much simpler and less code, has less dependencies, should work on Win32, defaults to unicode, and more importantly doesn't use system() so we can still do stuff while the editor is running. For example, timesheet tracking that is accurate even when the user suspends their laptop.

As an aide for testing, if STDOUT is not connected to a terminal then no editor will be started and the result method will return the txt attribute.


The new() constuctor takes the following arguments.

By default the editor is started when the object is created. Set auto to a false value to inhibit this behaviour.
The Perl IO layer encoding to write and read the file with. Defaults to ':utf8'. Set it to ':raw' to get binary mode.
The editor executable to run. If this is not given then the EDITOR environment variable will be used, and if that is empty then the following programs will be searched for using File::Which: sensible-editor, vim, vi, emacs, nano notepad. You can override the search list by setting @App::bif::Editor::EDITORS.
The contents to write to the file before the editor starts. Note that this will OVERWRITE the contents of the filename attribute!
A Path::Tiny filename to edit. Defaults to a temporary file.


The process ID of the editor program.


Open the editor if it is not running. Can be called safely when the editor is already running.
Returns the contents of the filename.
Wait for the editor process to finish.

See Also

Proc::FastSpawn, Proc::InvokeEditor


Mark Lawrence <>

Copyright And License

Copyright 2014-2017 Mark Lawrence <>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.