Skip to content

Instantly share code, notes, and snippets.

@ysasaki
Created October 6, 2010 09:29
Show Gist options
  • Save ysasaki/613078 to your computer and use it in GitHub Desktop.
Save ysasaki/613078 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
# Usage: read-password.pl --user hoge -p
use strict;
use warnings;
use Term::ReadPassword;
use Data::Dumper;
use Getopt::Long;
my %options;
my $ret = GetOptions( \%options, 'user|u=s', 'password|p', );
if ( $options{password} ) {
RETRY: {
my $password = read_password('New password: ');
my $confirm = read_password('Re-type new password: ');
if ( $password eq $confirm ) {
$options{password} = $password;
}
else {
goto RETRY;
}
}
}
print Dumper(\%options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment