in reply to Re^2: Executing Commands with "open"
in thread Executing Commands with "open"
Where is this buffer??
It's part of the system file handle.
Doesnt it count as memory?
It holds data, so it's some form of memory by definition.
But it's a rather small (64k?), fixed-size buffer.
So according to what you said the output is stored in this buffer. Backticks empty them into a scalar all at once.
No. That would require the output of the child to fit in the buffer, but that's impossible since it's a fixed-size buffer. Backticks repeatedly and continually empty the pipe into a scalar. Backticks is more or less equivalent to
my $pid = open(my $fh, '-|', $cmd); my $scalar = ''; 1 while sysread($fh, $scalar, BLK_SIZE, length($scalar)); waitpid($pid, 0); return $scalar;
The scalar keep growing and growing.
Update: Added the first two answers.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Executing Commands with "open"
by BrowserUk (Patriarch) on Jun 14, 2010 at 18:29 UTC | |
by ikegami (Patriarch) on Jun 14, 2010 at 19:06 UTC | |
|
Re^4: Executing Commands with "open"
by abhijithtk (Novice) on Jun 14, 2010 at 18:40 UTC |