in reply to 2 way pipe?

You can do that with two pipes and a fork.

my ($pread, $cwrite, $cread, $pwrite, $cpid); pipe $pread, $cwrite; pipe $cread, $pwrite; select((select($pwrite),$|=1)[0]); # added { $cpid = fork; defined $cpid or die $!; last if $cpid; close $pwrite or die $!; close $pread or die $!; open STDIN, '<&'.fileno($cread) or die $!; open STDOUT, '>&'.fileno($cwrite) or die $!; $|=1; # added exec $cmd; die $!; } close $cwrite or die $!; close $cread or die $!; # do your stuff

There is also Open2 or Open3 if you don't want to do the dirty work yourself.

Remember to call waitpid $cpid; after you're done and the pipes are closed. Otherwise you get zombies.

Update: The output pipes should be set to autoflush. Added code marked.

After Compline,
Zaxo