in reply to Re: "close" failing
in thread "close" failing

I don't think that $ENV{PATH} has anything to do with the failure of the close statement. It would affect the success of open, but not close. Or am I missing something?

Remember: There's always one more bug.

Replies are listed 'Best First'.
Re^3: "close" failing
by duff (Parson) on May 31, 2006 at 14:55 UTC

    The return value of a piped open tells you if the fork succeeded or not, the return value of close tells you about the execution status of the program in the pipe. So, if $ENV{PATH} is set such that perl can't find the program to be piped to/from, close will return a false value (perl was able to successfully fork, but not execute the piped command).

      I tried this, and it doesn't work as you described: If Perl can't find the program to be piped to, the open command fails.

      Remember: There's always one more bug.

      I'm not entirely sure that's correct. For my test code, if the program cannot be found, open will not succeed.

      #!/usr/bin/perl -w use strict; open(BAD, "/no-such-path/not_here.sh |") || die "Died with: $!\n"; close(BAD);
      Does in fact die on open with Died with: No such file or directory.

      -- vek --
Re^3: "close" failing
by munishdev (Initiate) on May 31, 2006 at 14:06 UTC
    thanks a lot for the replies. You are right here. Because the print statements worked fine after the open call. (in "do processing" section). So, it cannot be that open has failed.