#!/usr/bin/perl -w #test1.pl use IPC::Open2; use IO::Handle; use strict; my $output = ''; my $program = 'test2.pl'; my ($infh,$outfh) = (IO::Handle->new, IO::Handle->new); open2($infh, $outfh, ($program)); print $outfh "The rain in Spain stays mainly on the plain.\n"; while (<$infh>) { $output .= $_; } close($outfh); close($infh); print $output; exit; #### #!/usr/bin/perl -w #test2.pl use strict; my $input = ''; my $error = "We received nothing!"; while (my $line = ) { $input .= $line; } if ($input ne '') { print "We received input:\n"; print $input; } else { print $error; } exit;