I want to get the size of a file on disk in megabytes. Using the -s
operator gives me the size in bytes, but I'm going to assume that then diving this by a magic number is a bad idea:
my $size_in_mb = (-s $fh) / (1024 * 1024);
Should I just use a read-only variable to define 1024 or is there a programmatic way to obtain the size of a byte?
EDIT: Updated the incorrect calculation.