Shilpa Arvind wrote: > HI, > > I have started learning PERL recently. I wanted some explaination > regarding the following command. > > open(FILE, "|-") >
Perl implicitly forks a child process. the FILE file handle is opened with write access in the parent process. what the parent process writes to FILE can be read by the child process via STDIN. this allows you to do simple ipc communication between the parent and the child process. for example: #!/usr/bin/perl -w use strict; $SIG{CHLD} = 'IGNORE'; my $id = open(FILE,'|-'); die unless defined $id; if($id){ select(FILE); $| = 1; while(<>){ last if /quit/i; print FILE; } }else{ while(<>){ chomp; print length,"\n"; } } __END__ [panda]# open.pl abcd 4 1234567890 10 xyz 3 quit [panda]# david -- s$s*$+/<tgmecJ"ntgR"tgjvqpC"vuwL$;$;=qq$ \x24\x5f\x3d\x72\x65\x76\x65\x72\x73\x65 \x24\x5f\x3b\x73\x2f\x2e\x2f\x63\x68\x72 \x28\x6f\x72\x64\x28\x24\x26\x29\x2d\x32 \x29\x2f\x67\x65\x3b\x70\x72\x69\x6e\x74 \x22\x24\x5f\x5c\x6e\x22\x3b\x3b$;eval$; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>