title: How to use variable instead of a file handle
body: <p>I have a big data file <code>dump.all.lammpstrj</code> which I need to split/categorize into a series of files, such as <code>Z_1_filename</code>, <code>Z_2_filename</code>, <code>Z_3_filename</code> etc. based on the coordinates in each record.</p>
  
  <p>The coordinates are saved in a disordered way, so my program reads each line and determines which file this record should be sent to.</p>
  
  <p>I use a variable, <code>$filehandle = "Z_$i_DUMP"</code></p>
  
  <p>and I hope to open all of the possible files like this</p>
  
  <pre><code>for ( my $i = 1; $i &lt;= 100; $i++ ) {
    $filehandle = "Z_$i_DUMP";
    open $filehandle,'&gt;', "Z_$i_dump.all.lammpstrj.dat";
    ...
  }
  </code></pre>
  
  <p>But when running my program, I get a message</p>
  
  <blockquote>
    <p>Can't use string ("Z_90_DUMP") as a symbol ref while "strict refs" in use at ...</p>
  </blockquote>
  
  <p>I don't want to scan all the data for each output file, because <code>dump.all.lammpstrj</code> is so big that a scan would take a long time.</p>
  
  <p>Is there any way to use a defined variable as a file handle?</p>