#!/usr/bin/perl use strict; use warnings; my $pipe; open $pipe, '|-', '/bin/sh'; while () { print $pipe $_; } close $pipe; __DATA__ echo "hello world" for i in 1 2 3 4; do printf "this is iteration %d of the loop\n" $i done