in reply to Controlling the shell...

Another option is to use the Net::SSH::Perl module. It allows you to run commands thru ssh in a much more elegant way.