Hi Shlomi
I used your example code and the 'hello' did not appear on the input field. The
'$' did as the prompt. So I couldn't edit the 'hello'. I had to enter it in.
Below is the example output:
Output:
$ <typed in 'hello'>
You've given 'hello'
$
What I wanted was:
$Hello
You've given 'hell'
$
As you can tell the 'hello' is shown. I want to delete a single character in
the above example to get Hell. The code I used was:
#!/usr/bin/perl -w
# test readline.
use strict;
use warnings;
use Term::ReadLine;
my $rl = Term::ReadLine->new ('test');
while (my $text = $rl->readline('$', 'Hello'))
{
print "You've given '$text'\n";
}
So it appears the line in the while ignores the 'hello' parameter.
Thanks for the code. Any other ideas?
Sean
On 08/02/2012, at 7:01 PM, Shlomi Fish wrote:
> Hi Sean,
>
> On Wed, 8 Feb 2012 18:37:37 +1100
> Sean Murphy <[email protected]> wrote:
>
>> Hi All.
>>
>> This should be a simple task. But for the life of me, I cannot work it out.
>> I have a chunk of text in an scaler. I want to edit this text. I look at
>> Term::ReadLine and couldn't see a way of inserting the text into the edit
>> area. There is addhistory which adds to the history buffer. but this isn't
>> want I want.
>>
>> For example:
>>
>> $text = "this is a test";
>> $text = function ($text); # permits full editing of line.
>> print "$text\n";
>>
>> When script is executed. The text in $text is displayed. The cursor and
>> delete commands work. So the line can be modified.
>>
>> so how can this be done? I haven't seen any modules that seem to permit
>> this. Example code would be great.
>>
>> This is for a program I am writing to handle my home budgets. I am
>> extracting the text from a database using DBI.
>>
>
> After reading https://metacpan.org/module/Term::ReadLine::Gnu I came up with
> the following program which appears to start with the string "Hello". Hope it
> helps:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> use Term::ReadLine;
>
> my $rl = Term::ReadLine->new;
>
> while (my $text = $rl->readline('$', 'Hello'))
> {
> print "You've given '$text'\n";
> }
>
> =================
>
> Regards,
>
> Shlomi Fish
>
>
>> Sean
>
>
>
> --
> -----------------------------------------------------------------
> Shlomi Fish http://www.shlomifish.org/
> Free (Creative Commons) Music Downloads, Reviews and more -
> http://jamendo.com/
>
> And the top story for today: wives live longer than husbands because they are
> not married to women.
> — Colin Mochrie in Who’s Line is it, Anyway?
>
> Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/