addy2000 has asked for the wisdom of the Perl Monks concerning the following question:

Greetings,

From STDIN, i want that if the user presses tab, it will complete the word he has half typed - from (keys %hash).

How can this me done, O wise monks??

With Regards.

  • Comment on Tab completion for mundane input in perl

Replies are listed 'Best First'.
Re: Tab completion for mundane input in perl
by 1Nf3 (Pilgrim) on Jul 14, 2009 at 11:44 UTC

    This can be done with Term::ReadLine.

    Take a look at this wise reply of shmem: Re: Autocomplete in perl console application

    Update:

    Some sample code using another module, Term::Complete. Tested under Cygwin console.

    #!/usr/bin/perl -w use strict; use Term::Complete; my %hash = ( key1 => 'value1', key2 => 'value2', anotherkey => 'value3', fourthone => 'value4', ); my $user_input = Term::Complete::Complete('Try to input hash key: ', k +eys %hash);

    Regards,
    Luke

      Thx!!

      That did it for me

      Hello, I am having problems with cygwin using Term::Complete. Are there modifications required to module for it to work under cygwin? Seems to work fine under linux. Thanks,