If you can use
Tk , this will do it in a GUI. It pops the GUI, gets the user and pass, then undefines the password after it is used to authorize.
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
my ($user, $password);
my $mw = MainWindow->new;
$mw->title("Password Entry");
$mw->withdraw; # let size be determined before centering
$mw->fontCreate('big',
-weight=>'bold',
-size=> 14
);
my $buttom = $mw -> Button(-text => "SUBMIT",
-font => 'big',
-bg => 'white',
-command => \&somesub)
->pack(-side => 'bottom',-anchor => 'center');
my $label = $mw -> Label(-text => "Enter User and Password",
-font => 'big',
-bg => 'white',
)->pack(-side => 'top',
-anchor => 'center');
my $label1 = $mw -> Label(-justify => 'left',
-text => "User: ",
-font => 'big',
-bg => 'white',
) ->pack(-side => 'left', -expand => 1);
my $entry = $mw -> Entry(-selectborderwidth => 10,
-font => 'big',
-bg => 'white',
)->pack(-side => 'left',
-expand => 1);
###############################################################
my $label2 = $mw -> Label(-justify => 'left',
-text => "Password: ",
-font => 'big',
-bg => 'white',)
->pack(-side => 'left', -anchor => 'n');
my $entry1 = $mw -> Entry(-selectborderwidth => 10,
-show => "*",
-font => 'big',
-bg => 'white',
)->pack(-side => 'top',
-anchor => 'w');
##############################################################
# an enter in the password entry will submit
$entry1->bind('<Return>',[\&somesub]);
$entry->focus;
center($mw);
MainLoop;
sub somesub {
$user = $entry->get;
chomp $user;
$password = $entry1->get;
chomp $password;
#print "$user $password";
$mw -> destroy;
}
sub center {
my $win = shift;
$win->withdraw; # Hide the window while we move it about
$win->update; # Make sure width and height are current
# Center window
my $xpos = int(($win->screenwidth - $win->width ) / 2 );
my $ypos = int(($win->screenheight - $win->height ) / 2 );
$win->geometry("+$xpos+$ypos");
$win->deiconify; # Show the window again
}
# now Tk is finished, you can send the $user and $password to your ser
+ver
# your script continues here, the prints are just for demo purposes he
+re
print "Hit Enter to continue and send info to server\n";
<>;
# send to server or wherever
print "user->$user password->$password\n";
# now undefine password
$password = undef;
print "Hit Enter to exit, password is undefined\n";
<>;