capturing STDOUT from and piped "into" program
- From: Tim <tbrazil@xxxxxxxxxxxx>
- Date: 1 May 2007 13:33:06 -0700
Hi
I've read a lot good info on this list about capturing STDOUT but I'm
still having a problems grasping it. I think I'm missing something. I
am trying to capture the output from the "$p4 $spectype -i" command
and place it in a $scalar. I know I can't redirect directly into a
scalar.
open(FULLSPEC,"|$p4 $spectype -i");
print FULLSPEC @fullspec;
close(FULLSPEC);
Can someone please show me an example on how I can directly place the
output of the above example into a scalar variable?
Up to now I've cludged it by placing the output into a file and then
reading it however it's ugly.
open(FULLSPEC,"|$p4 $spectype -i > $outfile");
print FULLSPEC @fullspec;
close(FULLSPEC);
open(OUTPUT,"<$outfile");
$specout = <OUTPUT>;
close(OUTPUT);
chomp($specout);
unlink($outfile);
return $specout;
.
- Follow-Ups:
- Re: capturing STDOUT from and piped "into" program
- From: xhoster
- Re: capturing STDOUT from and piped "into" program
- From: Paul Lalli
- Re: capturing STDOUT from and piped "into" program
- Prev by Date: Install Mail::RBL failed in CPAN, how to fix it?
- Next by Date: Re: Access hash of hashes element problem.
- Previous by thread: Install Mail::RBL failed in CPAN, how to fix it?
- Next by thread: Re: capturing STDOUT from and piped "into" program
- Index(es):