in reply to SSH connection to 100 routers
There is a tool called rancid that handles this via expect. The expect man page is actually pretty good and should give you a decent overview of what it can do.
I think the rancid devs use the shell version of expect via a bash script (I haven't looked in quite a while so I'm not sure).
CPAN has a few Expect modules. Rex::Helper::SSH2::Expect looks interesting but I have no experience with it.