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

Re: Passing ouput between program

by synapse0 (Pilgrim)
on Jul 16, 2001 at 16:07 UTC ( [id://96999]=note: print w/replies, xml ) Need Help??


in reply to Passing ouput between program

Well, asking the sage advice of the One True Perl Guru, Guru perldoc (perldoc -f open from the cmd line), we find this:
If MODE is `'|-'', the filename is interpreted as a command to which output is to be piped, and if MODE is `'-|'', the filename is interpreted as a command which pipes output to us. In the 2-arguments (and 1-argument) form one should replace dash (`'-'') with the command. See the Using open() for IPC entry in the perlipc manpage for more examples of this. (You are not allowed to `open' to a command that pipes both in and out, but see the IPC::Open2 manpage, the IPC::Open3 manpage, and the Bidirectional Communication entry in the perlipc manpage for alternatives.)
and this example
open(ARTICLE, '-|', "caesar <$article") # decrypt article + or die "Can't start caesar: $!";
Which could just as easily be:
open(FH, '-|', "myscript.pl") or die "He's dead, Jim :$!"; while(<FH>) { do whatever with output form myscript } close(FH);
So, you can snarf info from one scripts output to your script using this method, or one of the IPC::OpenX methods.
Hopefully, that'll give some help.
-Syn0

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-26 05:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found