title: How can I check the extension of a file using Perl?
body: <p>To my perl script, a file is passed as an arguement. The file can be a <code>.txt</code> file or a <code>.zip</code> file containing the <code>.txt</code> file.</p>
  
  <p>I want to write code that looks something like this</p>
  
  <pre><code>if ($file is a zip) {
  
      unzip $file
      $file =~ s/zip$/txt/;
  }
  </code></pre>
  
  <p>One way to check the extension is to do a split on <code>.</code> and then match the last result in the array (returned by split).</p>
  
  <p>Is there some better way?</p>