#!/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!
In reply to Re: lines written to stdout by a backtick command
by sk
in thread lines written to stdout by a backtick command
by oceanic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |