title: Rename a file with perl
body: <p>I have a file in a different folder I want to rename in perl, I was looking at a solution earlier that showed something like this:</p>
  
  <pre><code>#rename
  for (&lt;C:\\backup\\backup.rar&gt;) {
      my $file = $_;
      my $new = $file . 'backup' . $ts . '.rar';  
      rename $file, $new or die "Error, can not rename $file as $new: $!";
  }
  </code></pre>
  
  <p>however backup.rar is in a different folder, I did try putting "C:\backup\backup.rar" in the &lt;> above, however I got the same error. </p>
  
  <pre>C:\Program Files\WinRAR>perl backup.pl
  String found where operator expected at backup.pl line 35, near "$_ 'backup'"
          (Missing operator before 'backup'?)
  syntax error at backup.pl line 35, near "$_ 'backup'"
  Execution of backup.pl aborted due to compilation errors.
  </pre>
  
  <p>I was using </p>
  
  <pre><code># Get time
  my @test = POSIX::strftime("%m-%d-%Y--%H-%M-%S\n", localtime);
  print @test;
  </code></pre>
  
  <p>To get the current time, however I couldn't seem to get it to <a href="http://perldoc.perl.org/functions/rename.html" rel="nofollow noreferrer">rename</a> correctly. </p>
  
  <p>What can I do to fix this? Please note I am doing this on a windows box.</p>