I'm guessing that you want to write a script with Perl. Otherwise your question is off-topic. :)
I don't know how CISCO routers handle ssh sessions, but if you want to automate ssh connections, I think your best best is public key with empty passphrase. If a script can decrypt whatever password by whatever means, so can your perpetrator (once he gets your script). (Hmmm.... My answer is completely devoid of Perl content.)
With public key, you'll have to guard your private key to the best of your abilities.