Sep 19, 2013, 12:49 PM
Post #4 of 4
Congratulations on fixing your script. However, I can suggest a few improvements.
Re: [praveensingh] Error: Access denied for user 'root
[In reply to]
Always (Yes ALWAYS) use strict. In the extremely rare cases where you must not have it, turn it off in the smallest possible scope. It does require some effort to declare all your variables (usually with my), but it will prevent many hard-to-find errors.
There is a subtle difference between <> and <STDIN>. Use the latter only when you are certain that you need it.
You are using the default value (space) of the special variable $" in your statement If you define $" in you code, you will not be confused by those spaces the next time you have to modify your code.
There is some advantage in using a module to prompt for username and password. Not all prompt modules are available on all platforms. None of the modules have all the features you might want. Look for a module that sets a default, validates the input, allows the user to fix any errors (or optionally abort), hides the password while the user is typing, and gets rid of the newline for you.