On 04/21/18 23:28, john doe wrote:
On 4/21/2018 9:58 PM, David Christensen wrote:On 04/21/18 08:38, john doe wrote:Here's the code I used to let a script prompt for a password: read -s -p "Enter password: " [ $? -ne 0 ] && exit 1I only speak shell scripting, how would you do that in Perl?
2018-04-22 11:21:56 dpchrist@vstretch ~/sandbox/perl $ cat console-input-noecho #!/usr/bin/env perl use strict; use warnings; use Data::Dumper; use Term::ReadKey; print 'Please enter key: '; ReadMode 'noecho'; my $key = ReadLine 0; print "\nPlease confirm: "; my $key2 = ReadLine 0; ReadMode 'normal'; print "\n"; print Data::Dumper->Dump([$key, $key2], [qw(key key2)]); 2018-04-22 11:22:02 dpchrist@vstretch ~/sandbox/perl $ perl console-input-noecho Please enter key: Please confirm: $key = 'secret '; $key2 = 'typo '; David