use strict; use warnings; open(my $out_fh, "|-", qw'ssh bash -s') or die "Can't start ssh: $!"; print$out_fh < EOF close $out_fh or die "Error flushing/closing pipe to ssh: $!";