sub readPassword { my ($prompt) = @_; $prompt ||= 'password: '; my $password; if (eval "require Term::ReadKey") { # runtime load Term::ReadKey->import(qw/ReadMode ReadLine/); local $|=1; ReadMode('noecho'); print STDERR $prompt; chomp($password = ReadLine(0)); ReadMode('normal'); print STDERR "\n"; } else { print STDERR "WARNING: Unable to load Term::ReadKey -- TYPED PASSWORDS WILL BE ECHOED!\n"; print STDERR $prompt; chomp ($password = ); } return $password; }