Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: pre-texted <STDIN>

by Corion (Pope)
on Apr 04, 2020 at 10:53 UTC ( #11115030=note: print w/replies, xml ) Need Help??


in reply to pre-texted <STDIN>

Unless you want to write your own text editor, just spawn the text editor your user wants, to edit their document, using Proc::InvokeEditor:

use Proc::InvokeEditor; my $unedited_text = read_text_from_existing_note('note.txt'); my $edited_text = Proc::InvokeEditor->edit($unedited_text); write_text_to_existing_note('note.txt'); # update # or alternatively system($ENV{EDITOR}, '/tmp/note.txt') == 0 or warn "Couldn't launch editor '$ENV{EDITOR}': $!";

Replies are listed 'Best First'.
Re^2: pre-texted <STDIN>
by ShainEdge (Novice) on Apr 04, 2020 at 11:31 UTC
    That is an awesome response! Problem is with most programming languages is that you know there might be a simple solution, but without someone who has walked that walk before, sometimes the solution doesn't seem to have any way to get from here to there, in finding it. You know there is a package, but how do you know that "InvokeEditor" exists, much less that it does what you wanted it to.

      The CPAN search can help you find packages, and in this case, I saw when the module was released and have used it since.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11115030]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2020-06-01 16:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (5 votes). Check out past polls.

    Notices?