Top

d/l speed calc. + size conv.


Perl Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  9.0 (of 1 scores)
Date Added  Jul 26, 2009
Last Updated  Jul 26, 2009
Tags  file  kb  mb  perl  size 

Introduction

This simple snippet can calculate the time required to download a particular file , and can convert KB(s) into MB(s) and Kb(s).

Grab the Code

#!/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" ;
}
 

Comments

  (2)  RSS
Kasbah
Comments: 18
 
Perl Snippet:  d/l speed calc. + size conv.
Posted on Aug 8, 2009 10:26 pm
Brilliant Idea this.. this definately gives you a great start in improving on this, well done
Anish
Comments: 13
 
Perl Snippet:  d/l speed calc. + size conv.
Posted on Aug 8, 2009 10:41 pm
thanks a lot kasbah . Had not expected that good comment on my very first perl snippet . And thanks for rating

Btw , I'll be adding little more features soon


Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom