Welcome to the Monastery | |
PerlMonks |
Conditional module useby Nkuvu (Priest) |
on Apr 21, 2006 at 18:46 UTC ( [id://544962]=perlquestion: print w/replies, xml ) | Need Help?? |
Nkuvu has asked for the wisdom of the Perl Monks concerning the following question: Forgive me monks, for I have been slacking. It has been far too long since I wrote a useful Perl script. My Perl skills are a bit rusty, and I've super searched with overwhelming results. That is, too many results, I couldn't find what I needed (I searched for BEGIN, eval, and require). I'm attempting to update a script to request a password from a user. The current implementation has the password sent in on the command line in clear text. I'd like to make it so that the password is not echoed to the screen, which is simple enough using Term::ReadKey. The problem is that the script will be used on multiple machines, and I can't guarantee that the module will be installed. I can't even guarantee that the version of Perl installed will be greater than 5.6 or so. So rather than have someone install a module on each machine (which is feasible, really, just not my preferred route) I'd like to warn the user if their password is going to be echoed. And not die if the module is not installed, of course. I wrote a very quick hack of a script to see if I could get this to work:
On a machine with Term::ReadKey installed, it works just fine. But a machine without Term::ReadKey fails with the following:
It's the end of a long week, and I've spent a few hours looking at various require and BEGIN nodes. I'm not seeing why this would fail, and I've used similar Perl code in other scripts (requiring a different module). I'm sure I'm missing something obvious.
Back to
Seekers of Perl Wisdom
|
|