> On Tue, Aug 4, 2009 at 16:35, Bryan Harris<br...@harrisfam.net> wrote: > snip >>> 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. > snip > > I assume you changed the second string to "Uh.". If so, then that is > what is supposed to happen. $term->readline() prompts with the first > string with a default of the second. When you hit enter, the input is > stored in $answer. All my loop does with the answer is tell you what > you said.
I didn't change anything, actually -- it never printed the "8/2 Updated database" string. It prompted with the "Enter a date and note:", I typed "Uh." and that was it. Maybe my version of perl doesn't have a good Term::Readline::Perl? How do I find out? I'm on OS X 10.5, which is still at perl 5.8.8. > snip >> 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. > snip > > Package refers to the multiple readline backends which are implemented > as modules (Term::Readline::GNU, Term::Readline::Perl, etc.). Some of > these backends have more features than others, but you always have > access to a base level of functionality in Term::Readline::Perl. > > Stubs are short functions that don't do anything. They are needed in > case the backend does not provide a feature. The stub will be called > instead and do nothing. This will prevent the program from blowing > up, allowing it to run with reduced functionality. For instance, a > backend might not provide a history of previous entries. In that > case, addhistory won't do anything, but calling it won't cause a > runtime error. Makes sense. > A method is a subroutine called on an object: > > $obj->method(); I've never used objects -- do I need to understand them to use Term::Readline? Thanks again, I really appreciate it. - Bryan -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/