On Friday, Sep 5, 2003, at 07:45 US/Pacific, [EMAIL PROTECTED] wrote:
[..]
This may be very simple, however I am missing something. I want to pipe
information into a perl script. Yet, I can not figure out what type of
system variable it will use. $_ , @_ , or even %_.
do you mean pipe as in
./some_cmd | ./my_perl_code.plx
what you will be reading in that case is from STDIN as in
while(<STDIN>) {
# read the stuff in $_ if line oriented
}otherwise you will want to do the standard sysread(). read the perldoc on these - my handy dandy, test my side of the pipe template is found at:
<http://www.wetware.com/drieux/pbl/perlTrick/drieuxTemplates/DoCmd.txt>
This way I can work out the basic semantics for what most of the cases of
foo | bar
will work out to be...
or do you mean pipe as in
pipe(CHLDr, PRNTw);
pipe(PRNTr, CHLDw);
if (!($pid = fork())) {
open(STDIN, "<&CHLDr");
open(STDOUT, ">&CHLDw");
open(STDERR, ">&CHLDw");
close(PRNTw); close(PRNTr); #close(DTKERRr);
select(STDOUT) ; $|=1 ;
exec(" $CMD 2>&1");
exit;
}
#
# we are the parent side of the process
#
select(PRNTw); $|=1; select(STDOUT);
close(CHLDr); close(CHLDw); #close(DTKERRw);which again is a matter of reading the end of the pipe that is your end, and writing to the end of the pipe that you are ACKing on...
Since I am a DILBERT I of course do the funk like that so I remember, "me Parent, Me write on PRNTw, Me Read from CHLDr...." and then simplify my world by resetting stderr to stdout...
ciao drieux
---
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
