use strict; use warnings; use Term::UI; use Term::ReadLine; my $term = Term::ReadLine->new('test'); # Use default replies if not at interactive prompt $Term::UI::AUTOREPLY = (-t STDIN) ? 0 : 1; my $choice = $term->ask_yn( prompt => 'Your answer?', default => 'n', ); print "You chose '$choice'\n"; code>