open() and pipes
nick at ccl4.org
Wed Aug 2 19:24:07 BST 2006
On Tue, Aug 01, 2006 at 12:11:01PM +0100, David Cantrell wrote:
> I know that you can't do this ...
> open(FOO, '|program|')
> in perl to use an external program as a filter, and that the solution is
> to use IPC::Open2. But *why*? From taking a quick look at the procmail
> source*, it seems pretty easy to do. Yes, there's loads of caveats
> about buffering and so on, but if you need to do this, you need to do
> it, and the caveats apply just as much to IPC::Open2 as they would to
> doing it in the open() function.
> It just seems odd to me that this functionality is missing and that you
> need to use a module for it. Given that IPC::Open2 was bundled with the
> very first version of perl5, it seems odd that that functionality wasn't
> just rolled into open() at that time.
> Am I missing something obvious?
I suspect that IPC::Open2 is distinctly non-portable. You can fake up the
two current | options for open with temporary files for operating systems
that only provide the C call system(). Whereas a two-ended open really
needs a lot of the Unix fork semantics to make work.
But I don't know if that was the direct reason. It could be that
Larry didn't change the syntax for Perl 5, and the existing syntax was
derived as an interface to the Unix C routine popen(), which isn't
More information about the london.pm