Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

using Term::ReadLine::Gnu

by my_nihilist (Sexton)
on Mar 19, 2008 at 17:58 UTC ( #675043=perlquestion: print w/ replies, xml ) Need Help??
my_nihilist has asked for the wisdom of the Perl Monks concerning the following question:

I am having a hard time understanding the Term::ReadLine::Gnu documentation and there is very little else to be found on-line. Perhaps this error may light a bulb:

function is not of type rl_command_func_tPtr at /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Term/ReadLine/Gnu/XS.pm line 98.

This was produced with:
#!/usr/bin/perl -w use strict; use Term::ReadLine; # presuming Term::ReadLine::Gnu is present... my $term = new Term::ReadLine 'ReadLine test'; my $prompt = "type: "; $term->bind_key('61', \&insertxt); while (1) { my $input=$term->readline($prompt); } sub insertxt { $term->insert_text("hello!"); }
  • the "key" argument to bind_key (61) must be numeric.
    anyway, there is a whole slew of functions listed in the documentation that obviously presume a knowledge i don't have, because there are no usage examples or explanations, and i have grown tired guessing. I thot anything beginning with "int" is for C...
  • Comment on using Term::ReadLine::Gnu
    Download Code
    Re: using Term::ReadLine::Gnu
    by almut (Canon) on Mar 19, 2008 at 18:30 UTC

      I think you need to give the function a name first (with add_defun()), and then use that name in the bind_key() call

      ... $term->add_defun('insert-text', \&insertxt); $term->bind_key(61, 'insert-text'); ...
        hey now isn't that handy! Remind me not to bother with too much Term::Readline::Gnu in the future!

        anyway, thanks much almut

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: perlquestion [id://675043]
    Approved by planetscape
    help
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (15)
    As of 2015-07-06 17:54 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (80 votes), past polls