Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

(elbie): File Size Conversion

by elbie (Curate)
on Aug 14, 2001 at 20:18 UTC ( [id://104828]=note: print w/replies, xml ) Need Help??


in reply to File Size Conversion

If you find this useful, please feel free to use it. I can't remember where I grabbed the download time calculation from. I think I just went looking for large files on download.com. :)

my $size = ( stat "$filename" )[7]; my $sizeunit = "b"; my $dltime = $size / 430080; if( $dltime < 1.0 ) { $dltime = "less than 1"; } else { $dltime = sprintf "%.0f", $dltime; } $dltime .= " min"; if( $size > 1024.0 ) { $sizeunit = 'Kb'; $size /= 1024.0; } if( $size > 1024.0 ) { $sizeunit = 'Mb'; $size /= 1024.0; } $size = sprintf( "%.1f %s", $size, $sizeunit );

elbieelbieelbie

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://104828]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-25 19:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found