in reply to lines written to stdout by a backtick command
#!/usr/bin/perl -w # Program: printsth print join (' ', @ARGV), $/ for (1..10);
Now I call this program inside another program and capture it's output
#!/usr/bin/perl -w # Program: captpipe my $arg = "hi there"; print ("Going to call another perl program and capture it's output\n") +; open (PIPE,"printsth $arg | ") or die $!; while (<PIPE>) { print; }
when you just run printsth hi there you will get hi there\n 10 times.
when you execute the captpipe script you will see the same output.
Output
[sk]% captpipe Going to call another perl program and capture it's output hi there hi there hi there hi there hi there hi there hi there hi there hi there hi there
this is a better way to capture output than using backticks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: lines written to stdout by a backtick command
by oceanic (Novice) on Aug 15, 2005 at 07:26 UTC | |
by tlm (Prior) on Aug 15, 2005 at 08:54 UTC |