Your idea looks nice, but you should take a look at the Filter Module ,it is available from CPAN, with this you can write encripted Perl Code, so you would not have problems with the passwords in your scripts.
In the Wolf Book ( Mastering Algorithms with Perl ), you can find more about it in Chapter 13:Cryptography.
Shadox