Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Redirecting all output to a var for post processing?

by zigster (Hermit)
on Feb 13, 2001 at 15:27 UTC ( [id://58115]=note: print w/replies, xml ) Need Help??


in reply to Redirecting all output to a var for post processing?

Sorry I dont quite follow, if you want to make your program run quietly then just dont print anything to stdout??!! Could you not just concat any messages to an internal variable instead of printing. If you really want to

Do you mean that you want to capture stdout/stderr of a program that you fork? If that is the case then you could connect the child process to the parent via pipes and capture the op directly from the pipes (see below).

If you really want to capture stdout in this way you could wrap the program in a fork as in this incomplete example.

if ($pid = open(CHILD,"-|")) { while (<CHILD>) { $data .= $_; } print $data; } else { exec ("ls"); }
If you want to keep all the code in one module you could replace the exec with your parent code.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://58115]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 17:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found