http://www.perlmonks.org?node_id=11118402

puterboy has asked for the wisdom of the Perl Monks concerning the following question:

As part of a larger Perl program, I need to execute a local bash script on a remote machine. I would like to do the equivalent of:
#!/bin/bash ssh <remotehost> bash -s <<EOF <local bash script written here> EOF
but from within a perl script using either backticks or system to run the ssh command. Something like
#!/usr/bin/perl my $output = `ssh <remotehost> bash -s` <<EOF <local bash script written here> EOF
Note that I want to load the bash script from within the same perl file where the ssh command is run -- not load it from an external separate file. Note that I can't run Net::SSH since I don't have access to additional modules