The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Prompt::Timeout - prompt() with auto-selecting default value in case of inactivity


 use Prompt::Timeout;
 my $res = prompt ( $question, $default, $timeout );


This module provides only one function, prompt(), and it's exported by default.


 my $res = prompt ( $question, $default, $timeout );

Prints a $question and waits for the input. If no keys are pressed during $timeout seconds, $default is assumed. When pressing just Enter key, $default is assumed. If prompt() detects that it is not running interactively, $default will be used without prompting too.

If you want to disable inactivity timer if any key is pressed during prompt(), you can invoke it with another optional parameter:

 my $res = prompt ( $question, $default, $timeout, 1 );

Once a key is pressed, inactivity timer is disabled.

When $timeout value is omitted, it assumes 60 seconds.


Serguei Trouchelle <>

Prompt::Timeout uses partial code from ExtUtils::MakeMaker module.


Copyright (c) 2008-2010 Serguei Trouchelle. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.