title: How do I get the size of a file in megabytes using Perl?
body: <p>I want to get the size of a file on disk in megabytes.  Using the <code>-s</code> operator gives me the size in bytes, but I'm going to assume that then dividing this by a magic number is a bad idea:</p>
  
  <pre><code>my $size_in_mb = (-s $fh) / (1024 * 1024);
  </code></pre>
  
  <p>Should I just use a read-only variable to define 1024 or is there a programmatic way to obtain the amount of bytes in a kilobyte?</p>
  
  <p><strong>EDIT:</strong> Updated the incorrect calculation.</p>