Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.

Re^2: <STDIN> "anticipate" input?

by MidLifeXis (Monsignor)
on Aug 12, 2008 at 14:55 UTC ( [id://703906] : note . print w/replies, xml ) Need Help??

in reply to Re: <STDIN> "anticipate" input?
in thread <STDIN> "anticipate" input?

What you are trying to do of "anticipating the input" cannot be done, with the value being editable on the command-line.

Very strong words, considering the shell does it all the time.

There may not be a module to do this (and I am not fully convinced of this), but it most definitely can be done. At the very worst, you would need to push the prefill onto the line, and process the backspaces / ^H yourself.

Update: See Term::ReadKey as a very possible tool to use to implement this, and Re: <STDIN> "anticipate" input? points to Term::ReadLine, which also looks like it could work (see addhistory as a possible method to do this).