title: How to write the current timestamp in a Perl file?
body: <p>How do I write the current timestamp in a Perl file?  </p>
  
  <p>I have made a file named <code>myperl.pl</code> which will print the current timestamp. The file is given below:  </p>
  
  <pre><code>#!/usr/local/bin/perl
  @timeData = localtime(time);
  print "@timeData\n";
  </code></pre>
  
  <p>Now I am trying to redirect the output of this file into another text file. The script is below:  </p>
  
  <pre><code>#!/usr/local/bin/perl
  @myscript = "/usr/bin/myperl.pl";
  @myfile = "/usr/bin/output_for_myperl.txt";
  perl "myscript" &gt; "myfile\n";
  </code></pre>
  
  <p>While running this I am getting below error:  </p>
  
  <blockquote>
    <p>perl sample_perl_script.pl<br>
    String found where operator expected at sample_perl_script.pl line 4, near "perl "myscript""<br>
    (Do you need to predeclare perl?)<br>
    syntax error at sample_perl_script.pl line 4, near "perl "myscript""<br>
    Execution of sample_perl_script.pl aborted due to compilation errors.</p>
  </blockquote>