in reply to Re: Using system with mailx
in thread Using system with mailx

In addition to checking the result of the open() call, I would also recommend checking the result of the close() call, especially when the file handle is opened to a piped program.
    :
    close PIPE 
        or die $!;
    :

Replies are listed 'Best First'.
Re: Re: Re: Using system with mailx
by Anonymous Monk on Aug 06, 2003 at 15:22 UTC
    I just read "perldoc -f close" which leads me to an even better example showing a non-zero exit status. If mailx is having problems, not checking the result of the close() call could easily hide those problems.
        close PIPE
            or die $! || "exit status $?";
    
Re: Re: Re: Using system with mailx
by blue_cowdawg (Monsignor) on Aug 06, 2003 at 15:27 UTC

    While you are technically correct I have actually seen cases where turning warnings on will produce spew falsely about using "or die" on close. I just tried to duplicate it but I don't remember where I ran into it. (AIX?)


    Peter @ Berghold . Net

    Sieze the cow! Bite the day!

    Test the code? We don't need to test no stinkin' code! All code posted here is as is where is unless otherwise stated.

    Brewer of Belgian style Ales