title: Perl: print compilation warnings for do()
body: <p>I am using <code>do()</code> to execute a perl script. I wanted to make sure it was doing the right error checking, but I noticed that warnings don't get printed when I use <code>do()</code>. I left the following warning on purpose in my script. I see it when I run it on the command line</p>
  <pre><code>Useless use of numeric eq (==) in void context at utils/queryEvent/query_event.pl line 47.
  </code></pre>
  <p>When I use <code>do()</code>, this message is suppressed. I saw in <a href="https://perldoc.perl.org/perlvar#$@" rel="nofollow noreferrer">perlvar</a> that <code>$@</code> doesn't contain warnings, so I tried to add this before my call to <code>do()</code>, but I still don't see anything.</p>
  <pre><code>local $SIG{__WARN__} = sub {
      print &quot;Warning @_\n&quot;;
  };
  do(...);
  </code></pre>
  <p>Is there a way I can still print the compilation/parsing warnings?</p>
  <p>I'm using Perl v.5.22.1 on Windows 10.</p>
  <p><strong>Added edit:</strong><br />
  Both the script calling <code>do()</code> and the script being run through <code>do()</code> have <code>use strict;</code> and <code>use warnings;</code>. It is only the parsing warning that isn't showing up. If I call warn in the do script, then I see that (I'm assuming stderr).</p>
  <p><strong>Edit:</strong><br />
  Adding example script.<br />
  A minimal reproducible version is the following</p>
  <pre class="lang-perl prettyprint-override"><code>use strict;
  use warnings;
  
  sub test
  {
      return 1;
  }
  
  main:
  {
      (test() == 1);
  }
  </code></pre>
  <p>Calling script</p>
  <pre class="lang-perl prettyprint-override"><code>use strict;
  use warnings;
  
  main:
  {
      do('test.pl');
  }
  </code></pre>