If you were using anything but a windows system, you could just form the command line like this:
$command = "(do this && do that) >/dev/null 2>&1";
Maybe the default "cmd.exe" (or whatever gets used on windows to run commands via the system() call) provides some equivalent sort of idiom, if you know how to look that up... (or maybe you can set things up so that your "do this, and do that" stuff gets run via a bash.exe shell, so you can at least redirect output to some file that you can then delete -- possibly after reading it to check for error conditions?)

Apart from that, since the main problem is the fact that your perl script is running in an environment where all output to STDOUT goes to some browser client, what you have to do is to change the STDOUT file handle so that stuff written to that handle will end up somewhere else, like a scalar variable (read the output of perldoc -f open):

close STDOUT; open STDOUT, '>', \$variable; system( $command ); close STDOUT; # you might want to check what got put into $variable... open STDOUT, '>-'; # reopen the real stdout
UPDATE: the above snippet was not tested, and on testing it, it doesn't work as intended. See ikegami's reply to me.

In reply to Re: How to hide system(); output. by graff
in thread How to hide system(); output. by bcens

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.