in reply to pretending that the contents of a variable are files

Try to open a "double" pipe (assuming read from STDIN is possible):
open FILE, "|du -sk|" or die "$!"; print FILE `ls`; print while(<FILE>);
perldoc -f open for more information.

Edit: This is false... :(
As noted in the replies, IPC::Open2 was the correct solution. From perldoc IPC::Open2:

The open2() function runs the given $cmd and connects $rdrfh for reading and $wtrfh for writing. It's what you think should work when you try $pid = open(HANDLE, "|cmd args|"); The write filehandle will have autoflush turned on.

That was what confused my. I'm sorry for the error.
This is the syntax for Open2:

use IPC::Open2; $pid = open2(\*RDRFH, \*WTRFH, 'some cmd and args'); # or without using the shell $pid = open2(\*RDRFH, \*WTRFH, 'some', 'cmd', 'and', 'args'); # or with handle autovivification my($rdrfh, $wtrfh); $pid = open2($rdrfh, $wtrfh, 'some cmd and args'); # or without using the shell $pid = open2($rdrfh, $wtrfh, 'some', 'cmd', 'and', 'args');

Open3 gives you also STDERR.

Replies are listed 'Best First'.
Re^2: pretending that the contents of a variable are files
by chb (Deacon) on Jan 28, 2005 at 12:39 UTC
    perldoc -f open says (among other things):
    You are not allowed to "open" to a command that pipes both in *and* ou +t, but see IPC::Open2, IPC::Open3, "Bidirectional Communication with Another Process" in perlipc for alte +rnatives.
    so I suggest hopping to perldoc IPC::Open2 and perldoc IPC::Open3 directly... update: changed pre- to code-tags
Re^2: pretending that the contents of a variable are files
by merlyn (Sage) on Jan 28, 2005 at 12:35 UTC