Callum's suggestion is excellent, and unless you have a good reason not to I suggest you do that rather than what I will advise.
You could look into using ssh, rsh, or telnet and then run your script from that session. I suggest checking out
Net::Telnet,
Net::SSH and
Net::Rsh.
Good Luck
Josh