in reply to Problems with Term::ReadKey
Here's what I tried:exit 0 if $key eq 'q';
Update: If 'q' is a problem for you, substitute a fake password like 'quit', 'exit', 'bye', etc. for 'q';#!/usr/bin/perl -slw use strict; use Term::ReadKey; my $key = 0; my $password = ""; print "\nPlease input your password: "; ReadMode(4); while(ord($key = ReadKey(0)) != 10) { exit 0 if $key eq 'q'; if(ord($key) == 127 or ord($key) == 8) { chop($password); print "\b \b"; } elsif(ord($key) < 32) { (); } else { $password = $password . $key; print ord($key); } } ReadMode(0); print "\n\nYour super secret password is: $password";
|
|---|