Quickest wya would be to get the left over from begining. ...
print "Please enter your number:\n"; chomp($num=<STDIN>); $bytes = $num % $kilo; $num -= $bytes ... HTH, Mark G. ----- Original Message ----- From: SilverFox <[EMAIL PROTECTED]> Date: Monday, August 9, 2004 12:06 pm Subject: Re: File Size Calculator > Jose Alves De Castro wrote: > > > On Mon, 2004-08-09 at 14:53, David Dorward wrote: > >> On 9 Aug 2004, at 14:34, SilverFox wrote: > >> > >> > Hi all, I'm trying to writing a script that will allow a user > to enter > >> > a > >> > number and that number will be converted into KB,MB or GB > depending on > >> > the > >> > size of the number. Can someone point me in the right direction? > >> > >> What have you got so far? Where are you stuck? Getting user input > >> (where from)? Working out which order of magnitude the number is? > > > > I wouldn't do that (the part of finding the order of > magnitude)... I > > would probably keep on doing calculations while the numbers was > greater> then 1024... and in the end, when it was, the right > letter to append > > would be based on the amount of calculations done... > > > > I remember reading something about this on use.Perl ... it was a > while> ago, and I'm not sure whether it ever got into a module, > but the guy had > > written some wonderful code to do this :-) > > > >> Converting between kilo and mega et al? Showing the output? > >> > >> Show us some code. > >> > >> -- > >> David Dorward > >> <http://dorward.me.uk/> > >> <http://blog.dorward.me.uk/> > > I haven't put anything together as yet. Putting some if/elsif > statement > together would be the easies way I can think off. Something like: > > $kilo= 1024; > $Mega= 1048576; > $gig= 1073741824; > > print "Please enter your number:\n"; > chomp($num=<STDIN>); > > if ($num >= $gig) > { > "need code to do the convertion/rounding of given number" > print "you entered: $num\n"; > print "which is: > } elsif { > continue with the same format........ > > } > > The problem i'm having it converting/rounding the inputted number > into a > valid byte (KB/MB/GB) count. > > SilverFox > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>