use strict; use warnings; use Term::ReadLine; # I need this under windows: $ENV{TERM}=undef; my $term=Term::ReadLine->new("test"); print "Please enter a pattern:"; my $pattern = ; chomp $pattern; my @files = glob($pattern); print "there are ",scalar @files," different possibilities.\n"; my $choosen = ''; $term->Attribs->{completion_function} = sub { my ($text, $line, $start) = @_; return grep { /^$text/i } @files ; }; while ( defined ( $_ = $term->readline( 'choose>') ) ) { # a blank bare line is entered? redo the loop next if /^$/; if ($_=~/.*$/){ chomp $_; $choosen = $_; last; } } print "You choosen [$choosen]\n";