in reply to Win32::DirSize and GB amount of data
Why are you using use integer? I think that is the source of most of your problems.
Without that, Perl will transparently convert your integers to reals if they get bigger than 2**32. Using reals, Perl can happily handle integer values upto 2**53 with no loss of accuracy. This equates to 9,007,199,254,740,992 which is 8 petabytes or ~ 8 million Gigabytes.
So unless you are expecting to be using drives greater than that, forget use integer and all the stuff about "loosing accuracy" and just let Perl take care of it.
Some code to demonstrate:
#! perl -slw use strict; use Win32::DirSize; use Data::Dumper; dir_size( 'p:\\', my $info ); print Dumper $info; ## As a string print $info->{DirSize}; ## Same field as an integer print 0+$info->{DirSize}; ## Same value by combining the high and low parts into a float printf "%.f\n", ( $info->{HighSize} * 2**32 ) + $info->{LowSize}; my $dirsize = $info->{DirSize}; if( $dirsize < 2**10 ) { printf "%d bytes\n",$dirsize } elsif( $dirsize < 2**20 ) { printf "%.2f KB\n", $dirsize / 2**10 } elsif( $dirsize < 2**30 ) { printf "%.2f MB\n", $dirsize / 2**20 } elsif( $dirsize < 2**40 ) { printf "%.2f GB\n", $dirsize / 2**30 } elsif( $dirsize < 2**50 ) { printf "%.2f TB\n", $dirsize / 2**40 } elsif( $dirsize < 2**60 ) { printf "%.2f PB\n", $dirsize / 2**50 } else{ print "This number is probably wrong: $dirsize"; } __END__ [ 1:15:03.82] P:\test>DirSize.pl $VAR1 = { 'DirCount' => 3866, 'LowSizeOnDisk' => 140623872, 'HighSizeOnDisk' => 4, 'FileCount' => 67685, 'DirSizeOnDisk' => '17320493056', 'DirSize' => '46480798709', 'LowSize' => 3531125749, 'Errors' => [], 'HighSize' => 10 }; 46480798709 46480798709 46480798709 43.29 GB
|
|---|