[LA.pm] calling gzip from within perl
Jeremy Leader
jleader at alumni.caltech.edu
Wed Jun 29 12:02:29 PDT 2005
Peter Benjamin wrote:
> At 10:21 PM 6/28/2005, David Heayn wrote:
>> open(FILE, "gunzip $fileLoc |") or die "Cannot gunzip '$fileLoc': $!";
>> my @stuff = <FILE>;
>> close(FILE);
<snip>
>
> Does your script use STDIN? If so, then
> this method of re-using STDIN (the pipe after the filename in
> the open) would cause problems. They share the same /dev/*
> file name that STDIN uses. As it appears to be a CGI script
> I suppose you will not be able to re-use STDIN using the |
> inside the open.
But the snippet of code above doesn't use STDIN.
The idiom open(FILE, "commandline |")... runs commandline
and pipes its STDOUT to the handle FILE; it doesn't
affect the current process's STDIN handle at all.
Now if he'd written:
close STDIN;
open(STDIN, "commandline |")...
then your point about re-using STDIN would be a valid concern.
--
Jeremy Leader
jleader at alumni.caltech.edu
leaderj at yahoo-inc.com (work)
More information about the Losangeles-pm
mailing list