Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; my @word = qw(xxx yyy zzz); open(PF,"|grep xxx") or die "failed \n"; foreach(@word) { print "here \n"; print PF $_; } print "going to close filehandle\n"; close(PF) or die "failed\n"; print "here 2\n";
I thought i'll get 'xxx' but that's not what i've got. Then i changed print PF $_; to print PF "$_ \n"; and i got the result that i expect.
But i can't explain the real different of these 2 codes to my self.And i need your help.
It's looks when close(PF) eq to echo xxxyyyzzz |grep xxx.Thank you
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pipe, when this shell command is going to executed ?
by Skeeve (Parson) on Sep 08, 2006 at 20:51 UTC | |
|
Re: Pipe, when this shell command is going to executed ?
by derby (Abbot) on Sep 09, 2006 at 10:50 UTC |