Re: Editing line of text.
Hi Sean, On Wed, 8 Feb 2012 18:37:37 +1100 Sean Murphy mhysnm1...@gmail.com 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: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Editing line of text.
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 mhysnm1...@gmail.com 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: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Editing line of text.
Hi Sean, Let's follow the documentation, shall we? ) -- readline(PROMPT[,PREPUT]) Gets an input line, with actual GNU Readline support. Trailing newline is removed. Returns undef on EOF. PREPUT is an optional argument meaning the initial value of input. The optional argument PREPUT is granted only if the value preput is in Features. It's easy to check that Term::ReadLine::Stub (used as implementing module by default, it seems) doesn't support preput feature. Just check $rl-Features. But Term::ReadLine::Gnu does, as it's an interface to a very powerful {libreadline} term library. So install Term::ReadLine::Gnu module (if needed, libreadline-dev as well) - and have fun with preput text without changing a line in Shlomi code. ) -- iD 2012/2/8 Sean Murphy mhysnm1...@gmail.com 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 mhysnm1...@gmail.com 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: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Editing line of text.
Hi Igor, thanks for helping Sean and shedding light on the problem he had with my code. Regards, Shlomi Fish On Wed, 8 Feb 2012 15:02:49 +0200 Igor Dovgiy ivd.pri...@gmail.com wrote: Hi Sean, Let's follow the documentation, shall we? ) -- readline(PROMPT[,PREPUT]) Gets an input line, with actual GNU Readline support. Trailing newline is removed. Returns undef on EOF. PREPUT is an optional argument meaning the initial value of input. The optional argument PREPUT is granted only if the value preput is in Features. It's easy to check that Term::ReadLine::Stub (used as implementing module by default, it seems) doesn't support preput feature. Just check $rl-Features. But Term::ReadLine::Gnu does, as it's an interface to a very powerful {libreadline} term library. So install Term::ReadLine::Gnu module (if needed, libreadline-dev as well) - and have fun with preput text without changing a line in Shlomi code. ) -- iD -- - Shlomi Fish http://www.shlomifish.org/ Funny Anti-Terrorism Story - http://shlom.in/enemy The difference between a good student and a bad student is that a bad student forgets the material five minutes before the test, while a good student five minutes afterwards. — One of Shlomi Fish’s Technion Lecturer Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Editing line of text.
Hi, I have tried to install Term::REadLine::Gnu. Get the below errors when it is being make. Can CPan install libreadline-dev library? Running install for module 'Term::ReadLine::Gnu' Running make for H/HA/HAYASHI/Term-ReadLine-Gnu-1.20.tar.gz CPAN: Digest::SHA loaded ok (v5.47) CPAN: Compress::Zlib loaded ok (v2.024) Checksum for /var/root/.cpan/sources/authors/id/H/HA/HAYASHI/Term-ReadLine-Gnu-1.20.tar.gz ok CPAN: Archive::Tar loaded ok (v1.54) CPAN: File::Temp loaded ok (v0.22) CPAN: Parse::CPAN::Meta loaded ok (v1.40) CPAN.pm: Building H/HA/HAYASHI/Term-ReadLine-Gnu-1.20.tar.gz Found `/usr/lib/libtermcap.dylib'. llvm-gcc-4.2 -arch x86_64 -arch i386 -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector -I/usr/local/include -DHAVE_STRING_H rlver.c -o rlver -arch x86_64 -arch i386 -fstack-protector -L/usr/local/lib -lreadline -ltermcap ld: warning: directory not found for option '-L/usr/local/lib' ld: warning: directory not found for option '-L/usr/local/lib' The libreadline you are using is the libedit library. Use the GNU Readline Library. Warning: No success on command[/usr/bin/perl Makefile.PL] 'YAML' not installed, will not store persistent state HAYASHI/Term-ReadLine-Gnu-1.20.tar.gz /usr/bin/perl Makefile.PL -- NOT OK Running make test Make had some problems, won't test Running make install Make had some problems, won't install Could not read metadata file. Falling back to other methods to determine prerequisites I have a MAC Lion with Perl 5.12. If this makes any difference. Sean On 09/02/2012, at 12:02 AM, Igor Dovgiy wrote: Hi Sean, Let's follow the documentation, shall we? ) -- readline(PROMPT[,PREPUT]) Gets an input line, with actual GNU Readline support. Trailing newline is removed. Returns undef on EOF. PREPUT is an optional argument meaning the initial value of input. The optional argument PREPUT is granted only if the value preput is in Features. It's easy to check that Term::ReadLine::Stub (used as implementing module by default, it seems) doesn't support preput feature. Just check $rl-Features. But Term::ReadLine::Gnu does, as it's an interface to a very powerful {libreadline} term library. So install Term::ReadLine::Gnu module (if needed, libreadline-dev as well) - and have fun with preput text without changing a line in Shlomi code. ) -- iD 2012/2/8 Sean Murphy mhysnm1...@gmail.com 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 mhysnm1...@gmail.com 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
Editing line of text.
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. Sean -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/