#!/usr/bin/perl use strict; use warnings; my $module; BEGIN { my $opt = $ARGV[0]; $ENV{PERL_RL} = $opt || qw(Gnu Perl Zoid)[0]; # choose module $module = $ENV{PERL_RL}; } use Term::ReadLine; my $term = Term::ReadLine->new('sample'); my $attribs = $term->Attribs; completion_words('print', 'list', 'quit', 'run', 'status'); $term->readline("$module> "); sub completion_words { my @basic_commands = @_; my $c_completion = sub { my ($text, $line, $start) = @_; #return () if $start != 0; # only at start grep(/^$text/, @basic_commands); }; $attribs->{completion_function} = $c_completion; }