The only errors (I think) that could be caught from the open/close itself would be handled by the or die() part.

No, sorry, with a piped open you need to check close for errors as well, as described in close.

I have not found a way to redirect stderrr properly under Fast-CGI

I unfortunately don't have the time right now to spin up a FastCGI environment, but I would suggest trying both IPC::Run3, as well as a system call inside of Capture::Tiny's capture (as shown in its docs). I've had very good experiences with both of those modules.

As for the code snippet, the pipe gets opened and closed immediately because as it stands the output from the process it calls goes to the temporary file which is read later on further down in the script.

While I'm still having a bit of trouble matching your description to your code (maybe I'm just being dense at the moment), what I am getting from your code is that perhaps tidy is sending things to its STDOUT that you want to suppress using the piped open? Since the modules I named above capture both STDOUT and STDERR, again I'd suggest giving them a try.


In reply to Re: open/close and stderr by haukex
in thread File::Temp::tempfile : name versus handle by mldvx4

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.