title: How can I create a directory if one doesn't exist using Perl?
body: <p>Currently, my Perl output is hard-coded to dump into the following Unix directory:</p>
  
  <pre><code>my $stat_dir = "/home/courses/" . **NEED DIR VAR HERE**;
  </code></pre>
  
  <p>The filename is built as such:</p>
  
  <pre><code>$stat_file = $stat_dir . "/" . $sess.substr($yr, 2, 2) . "_COURSES.csv";
  </code></pre>
  
  <p>I need a similar approach to building Unix directories, but I need to check if they exist first before creating them.</p>
  
  <p>How can I do auto-numbering (revisions) of the $stat_file so that when these files get pumped into the same directory, they do not overwrite or append to existing files in the directory?</p>