logo       

Re: Emacs like line editing during perl input.: msg#00944

emacs.help

Subject: Re: Emacs like line editing during perl input.

[fu-t set]

in gnu.emacs.help i read:

>I'm sneaking in a perl question that is only slightly related to
>emacs.

it'd be a lot better answered in comp.lang.perl.misc or .modules.

>I'd like to have somekind of line editing available during user
>input to a perl script.
>
>By default it seems none is available. Any attempt to navigate or
>edit an input line produces control chars. Only backspace works to
>edit.

that's all that is provided by your system's terminal driver. (probably
there are some other functions too, but nowhere near what emacs provides.)
most likely you want to special case terminal input to use Term::ReadLine.

>I think Term::ReadLine is the tool for this but couldn't figure out
>how to deploy it.

,----[ from ``perldoc Term::ReadLine'' ]
| NAME
| Term::ReadLine - Perl interface to various "readline"
| packages. If no real package is found, substitutes stubs
| instead of basic functions.
|
| SYNOPSIS
| use Term::ReadLine;
| $term = new Term::ReadLine 'Simple Perl calc';
| $prompt = "Enter your arithmetic expression: ";
| $OUT = $term->OUT || STDOUT;
| while ( defined ($_ = $term->readline($prompt)) ) {
| $res = eval($_), "\n";
| warn $@ if $@;
| print $OUT $res, "\n" unless $@;
| $term->addhistory($_) if /\S/;
| }
`----

--
bringing you boring signatures for 17 years


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise