Have a look at Authen::Passphrase::BlowfishCrypt [1]. it handles a lot of my suggestions automatically and is more suited to your general-case than my code is.
[1] http://search.cpan.org/~zefram/Authen-Passphrase-0.007/lib/A...
[1] http://search.cpan.org/~zefram/Authen-Passphrase-0.007/lib/A...