Front page | perl.beginners |
Postings from August 2009
Re: better readline?
Thread Previous
|
Thread Next
From:
Bryan Harris
Date:
August 5, 2009 04:35
Subject:
Re: better readline?
Message ID:
C69E05AB.1DEB8%Bryan_R_Harris@raytheon.com
> On Mon, Aug 3, 2009 at 18:43, Bryan R Harris<Bryan_R_Harris@raytheon.com>
> wrote:
>>
>>
>> I'm writing a little script where the user enters some data via keyboard.
>>
>> The script in some cases can guess what the user will want to enter, but I'd
>> like the user to be able to override what the computer has guessed.
>>
>> For example, the computer thinks the user will enter "8/2 Updated database",
>> but the user may want to enter "8/2 Removed links table".
>>
>> Is there a way to have perl prompt the user thusly:
>>
>> Enter a date and note: 8/2 Updated database<cursor goes here>
>>
>> ... but then the user could backspace all the way back to 8/2 and change it
>> if they want? Almost like I'm pushing something into <STDIN>, which will
>> then get read back out?
>>
>> I'm not even sure what words to use to ask, but I hope that's clear enough??
>>
> snip
>
> It sounds like you want [Term::Readline][1]:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> use Term::Readline;
>
> my $term = Term::ReadLine->new("progname");
>
> while ( defined (my $answer = $term->readline("Enter a date and
> note:", "8/2 Updated database")) ) {
> print "you said $answer\n";
> }
Thanks for the response Chas -- oddly it doesn't work. This is what it
prints:
2054% ./test
Enter a date and note:Uh.
you said Uh.
I don't understand the documentation -- I don't know what a "package",
"stub", or "method" are in this context, and I've been perl coding for
nearly 10 years! Obviously experience doesn't always equate to expertise.
=)
- Bryan
Thread Previous
|
Thread Next