in reply to Executing Commands with "open"
Since even when we use the open method, isnt the entire output being stored somewhere and then being fetched to be printed out line by line?? If thats the case dont they use up the same amount of memory?
No, the data isn't stored anywhere.
In both case, the data is passed to Perl via a pipe (64k buffer?). The backticks empties the pipe into a scalar (or scalars in list context), where as the open method provides you a handle to the pipe so you can empty it yourself. The child will block if it tries to write to a full pipe.
Note that this form of open returns a pid, and you should call waitpid($pid, 0); to release the resource used by the child.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Executing Commands with "open"
by abhijithtk (Novice) on Jun 14, 2010 at 16:11 UTC | |
by JavaFan (Canon) on Jun 14, 2010 at 16:22 UTC | |
by ikegami (Patriarch) on Jun 14, 2010 at 16:56 UTC | |
by BrowserUk (Patriarch) on Jun 14, 2010 at 18:29 UTC | |
by ikegami (Patriarch) on Jun 14, 2010 at 19:06 UTC | |
by abhijithtk (Novice) on Jun 14, 2010 at 18:40 UTC |