go ahead... be a heretic | |
PerlMonks |
Re: Reading streams, perl variables when script is runningby kcott (Archbishop) |
on Jan 04, 2014 at 11:00 UTC ( [id://1069267]=note: print w/replies, xml ) | Need Help?? |
G'day xtpu, Welcome to the monastery. There are a number of FAQs (in perlfaq8 and perlfaq9) with information about passwords. The most relevant to your question would be "How do I ask the user for a password?"; although, the others may be of interest. You can put lexical variables in an anonymous scope to make them private. In the following demo script, only the subroutines initialise_password() and retrieve_password() have access to the $password variable: even if you accidentally used $password somewhere else in your code, it would be a completely different variable. The following code shows the techniques you might use to read the password once at startup, store it in a private variable and retrieve it as many times as you want.
Sample run:
-- Ken
In Section
Seekers of Perl Wisdom
|
|