#!perl use strict; use warnings; #use Term::ReadLine; ##http://bvr.github.io/2010/11/term-readline/ BEGIN { $ENV{PERL_RL}="Perl";$ENV{TERM} = 'not dumb' if $^O eq 'MSWin32';} $\="\n"; use Term::ReadLine; my $term=Term::ReadLine->new("test"); print $term->ReadLine; print $term->Attribs; use Data::Dump::Streamer; $term->Attribs->{completion_function} = sub { my ($text, $line, $start) = @_; return grep { /^$text/i } (qw( SELECT INSERT UPDATE DELETE FROM WHERE AS IN ASC DESC ),'ORDER BY'); }; #foreach my $k (keys $term->Attribs){print "$k ${$term->Attribs}{$k}\n"} #exit; #Dump %{$term->Attribs};exit; my %cmds = (alloid=>1,ammoid=>2); # THIS WORKS #&readline::rl_basic_commands(keys %cmds); # THE FOLLOWING CHECK DOES NOT WORK #if (exists &readline::rl_basic_commands){print "BEFORE WHILE EXISTS\n"; &readline::rl_basic_commands(keys %cmds);} while ( defined ( $_ = $term->readline( '>') ) ) { print "$_\n"; } continue{ # THIS CHECK WORKS INDEED! if (exists &readline::rl_basic_commands){print "IN CONTINUE EXISTS\n"; &readline::rl_basic_commands(keys %cmds);} }