LPM: filtering
Joe Hourcle
oneiros at dcr.net
Tue Mar 7 15:29:18 CST 2000
On Tue, 7 Mar 2000, Frank Price wrote:
> Yah, I know about Text::Wrap, and it works great. Seemed a shame to
> load a module just for that if I could roll my own though (although
> forking might be just as bad).
>
> Anyway, a more abstract version of my question is: Can I pipe to a
> program, print to it, and then read from that stdout so I can do
> something else with it? The "fork off another process" idea from the
> Cookbook seems to be what I want, but something's going wrong.
>From Programming Perl:
You may not have an open command that pipes both in and out,
although the IPC::Open2 and IPC::Open3 library routines give you a
close equivalent.
In your example, however, you knew what the arguments were that you were
passing it...
so you could just as easy call:
open (WHATEVER, "echo $input | program to send to |");
(of course, you'd have to make sure that you stripped out any characters
that might confuse the shell, which means, doing this badly could result
in a major security hole.)
-Joe
More information about the Lexington-pm
mailing list