G'day Monk::Thomas,
The documentation for the close function has information on filehandles associated with pipes. It includes this example code which (with appropriate modification) may be a better choice for your script:
... close OUTPUT or warn $! ? "Error closing sort pipe: $!" : "Exit status $? from sort";
"(I'm wondering why there's carp instead of croak, but that's a different issue.)"
carp will output a message and keep going while croak will output a message and terminate the script (see Carp for details).
You say the code you posted "is part of a subroutine". There could be any number of reasons for not terminating the script at this point. Without knowing what else the script is doing, it's impossible to say (including whether croak would be more appropriate).
-- Ken
In reply to Re: close $fh fails on a single host - looking for explanation
by kcott
in thread close $fh fails on a single host - looking for explanation
by Monk::Thomas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |