Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-26-2005, 12:37 PM   #1
Registered: Sep 2004
Location: Long Beach, CA
Distribution: FreeBSD,Ubuntu,Gentoo,MacOS
Posts: 139

Rep: Reputation: 15
Perl assistance requested...

I'm trying to create a small script that converts MB to GB for a karamba theme so that my memory and hard drives display in GB rather than MB when over 1000MB. This is what I have thus far but it doesn't produce what I need:

#!/usr/bin/perl -w

use strict;

my $value = $ARGV[0];

if ( $value > 1000 )
  $value = sprintf "%f", ( $value / 1000 );

print $value . "\n\n";

~ $ ./ 19335
I was hoping for 19.34 but I'm just not getting it.

Any assistance would be much appreciated.

Old 05-26-2005, 01:05 PM   #2
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
I think what you want is:
$value = sprintf "%.2f", ( $value / 1000 );

Last edited by david_ross; 05-26-2005 at 01:06 PM.
Old 05-26-2005, 03:01 PM   #3
Registered: Sep 2004
Location: Long Beach, CA
Distribution: FreeBSD,Ubuntu,Gentoo,MacOS
Posts: 139

Original Poster
Rep: Reputation: 15
Thanks. That worked...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
perl assistance... Ateo Programming 8 07-02-2005 08:07 PM
bash assistance requested.. Ateo Programming 3 02-09-2005 06:41 PM
Assistance Requested: Hardware selection for linux servers the_halfling Linux - Hardware 2 05-05-2004 07:05 AM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM
perl/sendmail/mailfilter help requested joesbox Programming 1 03-04-2003 11:07 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:58 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration