Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Schuk's scratchpad

by Schuk (Pilgrim)
on Jan 12, 2005 at 17:39 UTC ( [id://421677]=scratchpad: print w/replies, xml ) Need Help??

I open a pipe to a program:
open(PIPEWRITE, '|./program') or die "Can't start pipe: $!"; print PIPEWRITE for @array; close PIPEWRITE or die "Cant't close pipe: $!";
But how do I read the output of my pipe? I dont want to store it to a file like this
open(PIPEWRITE, '|./program > output');
Because I am doing several thousand executions. How can I store the ouput to an array?

Solution:

use IPC::Open2; my $pid = open2(\*RDRFH, \*WTRFH, './program'); print WTRFH @{$mail[0]}; close WTRFH; waitpid $pid, 0; my @array = <RDRFH>; close RDRFH;
http://www.perlmonks.org/index.pl?node_id=407972 would also work
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-26 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found