Revision: 3459
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 27, 2007 07:56 by micmath
Initial Code
sub ask { my($promptString, $defaultValue) = @_; if ($defaultValue) { print $promptString, "[", $defaultValue, "]: "; } else { print $promptString, ": "; } $| = 1; # force a flush after our print $_ = <STDIN>; # get the input from STDIN (presumably the keyboard) chomp; if ("$defaultValue") { return defined $_ ? $_ : $defaultValue; # return $_ if it has a value } return $_; }
Initial URL
Initial Description
Initial Title
Get user input on the command line.
Initial Tags
perl
Initial Language
Perl