title: How do I redirect stdout and stderr output from a Perl script to a file on Windows?
body: <p>I tried this:</p>
  
  <pre><code>test1.pl &gt;output.log 2&gt;&amp;1
  </code></pre>
  
  <p>but this is the result:</p>
  
  <pre><code>Can't dup STDOUT:  Permission denied at C:/Perl/lib/Test/Builder.pm line 1376.
  Compilation failed in require at C:/Perl/lib/Test/Builder/Module.pm line 3.
  BEGIN failed--compilation aborted at C:/Perl/lib/Test/Builder/Module.pm line 3.
  Compilation failed in require at C:/Perl/lib/Test/More.pm line 22.
  BEGIN failed--compilation aborted at C:/Perl/lib/Test/More.pm line 22.
  Compilation failed in require at C:/Perl/site/lib/Test/WWW/Selenium.pm line 72.
  BEGIN failed--compilation aborted at C:/Perl/site/lib/Test/WWW/Selenium.pm line 72.
  Compilation failed in require at C:\Software\selenium-remote-control-1.0-beta-2\tests\test1.pl line 5.
  BEGIN failed--compilation aborted at C:\Software\selenium-remote-control-1.0-beta-2\tests\test1.pl line 5.
  </code></pre>
  
  <p>The script runs file as long as I don't try to redirect the output from the command line in any way.</p>
  
  <p>Here's my script, just in case that helps.  (It's a <a href="http://seleniumhq.org/" rel="nofollow noreferrer">Selenium</a> test script):</p>
  
  <pre><code>#!C:/perl/bin/perl.exe -w
  use strict;
  use warnings;
  use Time::HiRes qw(sleep);
  use Test::WWW::Selenium;
  use Test::More "no_plan";
  use Test::Exception;
  
  my $sel = Test::WWW::Selenium-&gt;new( host =&gt; "localhost",
                                      port =&gt; 4444,
                                      browser =&gt; "*chrome",
                                      browser_url =&gt; "http://localhost/" );
  print "Start Time: " . localtime() . "\n";
  for (my $count = 3000; $count &gt; 0; $count--)
  {
      print $count . " tests remaining.\n";
      $sel-&gt;open_ok("/home");
      $sel-&gt;click_ok("link=News");
      $sel-&gt;wait_for_page_to_load_ok("30000");
      $sel-&gt;click_ok("video");
      $sel-&gt;wait_for_page_to_load_ok("30000");
      $sel-&gt;click_ok("link=Sports");
      $sel-&gt;wait_for_page_to_load_ok("30000");
      $sel-&gt;click_ok("link=Movies");
      $sel-&gt;wait_for_page_to_load_ok("30000");
      $sel-&gt;click_ok("moremovies");
      $sel-&gt;wait_for_page_to_load_ok("30000");
  }
  
  print "End Time: " . localtime() . "\n";
  </code></pre>