Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: "close" failing

by duff (Parson)
on May 31, 2006 at 14:55 UTC ( [id://552809]=note: print w/replies, xml ) Need Help??


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

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).

Replies are listed 'Best First'.
Re^4: "close" failing
by jdhedden (Deacon) on May 31, 2006 at 15:26 UTC
    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.
Re^4: "close" failing
by vek (Prior) on May 31, 2006 at 17:21 UTC

    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 --

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://552809]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-20 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found