This simple snippet can calculate the time required to download a particular file , and can convert KB(s) into MB(s) and Kb(s).
#!/usr/bin/perl -w
print "Type 1 for checking how much time it will take to download with a specified speed\n";
print "Type 2 to convert KBs into MBs and Kbs\n";
$choice = <STDIN>;
if ($choice == 1)
{
print "Enter the speed ( in KBps )\n" ;
$speed = <STDIN>;
print "Enter the file size of the file to be downloaded (in KBs)\n";
$size = <STDIN>;
$time_ = $size / $speed;
if ($time > 60)
{
$time_ = $time_/60; print $time_ ." minutes would be taken to download ". $size ." KB(s)\n";
}
else
{
print $time_ ." seconds would be consumed to download ". $size ." KB(s)\n";
}
}
else
{
print "Type the amount of KBs\n";
$size2 = <STDIN>;
$MBs = $size2 / 1024 ;
$Kbs = $size2 / 8 ;
print $MBs ." MBs and ". $Kbs ." Kbs\n" ;
}