Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Passing an array into an open command

by eXile (Priest)
on Mar 18, 2004 at 20:19 UTC ( [id://337793]=note: print w/replies, xml ) Need Help??


in reply to Passing an array into an open command

Mike, is the 'ticket' program expecting input from the command-line or on STDIN? If it is expecting input from STDIN and you want to process it's STDOUT, you can use IPC::Open2:

test3.pl (emulates 'ticket' program')
#!/usr/bin/perl -w use strict; while (<STDIN>) { print "PROCESSED $_"; }

test4.pl
#!/usr/bin/perl -w use strict; $|++; use IPC::Open2; my @loglines=("This is not a relevant logline", "This is not a relevant logline", "This might be an interesting logine", "Another interesting logline"); open2(*READ,*WRITE,"./test3.pl") or die; foreach my $inputline (@loglines) { print WRITE "$inputline\n"; } close (WRITE); my $outputline; while ($outputline = <READ>) { print $outputline; }
As a sidestep: if you use 'open', please check if it succeeds, like:
open(RUN, "/usr/local/bin/ticket @ABC|") or die "useful error message +here";

Log In?
Username:
Password:

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

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

    No recent polls found