Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 956 Categories, Downloaded 50.273.891 Times

Number::Bytes::Human 0.07

  Date Added: January 18, 2010  |  Visits: 1.209

Number::Bytes::Human

Report Broken Link
Printer Friendly Version


Product Homepage
Download (98 downloads)



Number::Bytes::Human is a Perl module that can convert byte count to human readable format. SYNOPSIS use Number::Bytes::Human qw(format_bytes); $size = format_bytes(0); # 0 $size = format_bytes(2*1024); # 2.0K $size = format_bytes(1_234_890, bs => 1000); # 1.3M $size = format_bytes(1E9, bs => 1000); # 1.0G # the OO way $human = Number::Bytes::Human->new(bs => 1000, si => 1); $size = $human->format(1E7); # 10MB $human->set_options(zero => -); $size = $human->format(0); # - THIS IS ALPHA SOFTWARE: THE DOCUMENTATION AND THE CODE WILL SUFFER CHANGES SOME DAY (THANKS, GOD!). This module provides a formatter which turns byte counts to usual readable format, like 2.0K, 3.1G, 100B. It was inspired in the -h option of Unix utilities like du, df and ls for "human-readable" output. From the FreeBSD man page of df: http://www.freebsd.org/cgi/man.cgi?query=df "Human-readable" output. Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte in order to reduce the number of digits to four or fewer using base 2 for sizes. byte B kilobyte K = 2**10 B = 1024 B megabyte M = 2**20 B = 1024 * 1024 B gigabyte G = 2**30 B = 1024 * 1024 * 1024 B terabyte T = 2**40 B = 1024 * 1024 * 1024 * 1024 B petabyte P = 2**50 B = 1024 * 1024 * 1024 * 1024 * 1024 B exabyte E = 2**60 B = 1024 * 1024 * 1024 * 1024 * 1024 * 1024 B zettabyte Z = 2**70 B = 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 B yottabyte Y = 2**80 B = 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 B I have found this link to be quite useful: http://www.t1shopper.com/tools/calculate/ If you feel like a hard-drive manufacturer, you can start counting bytes by powers of 1000 (instead of the generous 1024). Just use bs => 1000. But if you are a floppy disk manufacturer and want to start counting in units of 1024000 (for your "1.44 MB" disks)? Then use bs => 1_024_000. If you feel like a purist academic, you can force the use of metric prefixes according to the Dec 1998 standard by the IEC. Never mind the units for base 1000 are (B, kB, MB, GB, TB, PB, EB, ZB, YB) and, even worse, the ones for base 1024 are (B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB) with the horrible names: bytes, kibibytes, mebibytes, etc. All you have to do is to use si => 1. Aint that beautiful the SI system? Read about it: http://physics.nist.gov/cuu/Units/binary.html You can try a pure Perl "ls -lh"-inspired command with the one-liner, er, two-liner: $ perl -MNumber::Bytes::Human=format_bytes -e printf "%5s %sn", format_bytes(-s), $_ for @ARGV * Why to write such a module? Because if people can write such things in C, it can be written much easier in Perl and then reused, refactored, abused. And then, when it is much improved, some brave soul can port it back to C (if only for the warm feeling of painful programming)..

Requirements: No special requirements
Platforms: Linux
Keyword: Byte Bytes Format Human Readable Libraries Numberbyteshuman Perl Module Programming To Human
Users rating: 0/10

License: Freeware Size: 9.22 KB
USER REVIEWS
More Reviews or Write Review


NUMBER::BYTES::HUMAN RELATED
Libraries  -  Graph::Writer::TGXML 0.01
Graph::Writer::TGXML is a Perl module used to write out directed graph as TouchGraph LinkBrowser XML. SYNOPSIS use Graph; use Graph::Writer::TGXML; $graph = Graph->new(); # add edges and nodes to the graph $writer =...
4.1 KB  
Libraries  -  GPS::Lowrance 0.31
GPS::Lowrance is a Perl module connect to Lowrance and Eagle GPS devices. REQUIREMENTS The following modules are required to use this module: Carp::Assert GPS::Lowrance::LSI 0.23 Parse::Binary::FixedFormat Win32::SerialPort or...
22.53 KB  
Libraries  -  DateTime::Format::Epoch::TJD 0.10
DateTime::Format::Epoch::TJD is a Perl module that can convert DateTimes to/from Truncated Julian Days. SYNOPSIS use DateTime::Format::Epoch::TJD; my $dt = DateTime::Format::Epoch::TJD->parse_datetime( 13244.5 ); # 2004-08-27T00:00:00...
17.41 KB  
Libraries  -  DateTime::Format::Epoch::DotNet 0.10
DateTime::Format::Epoch::DotNet is a Perl module that can convert DateTimes to/from .NET epoch seconds. SYNOPSIS use DateTime::Format::Epoch::DotNet; my $dt = DateTime::Format::Epoch::DotNet->parse_datetime( 1051488000 );...
17.41 KB  
Libraries  -  DateTime::Format::Epoch::Unix 0.10
DateTime::Format::Epoch::Unix is a Perl module that can convert DateTimes to/from Unix epoch seconds. SYNOPSIS use DateTime::Format::Epoch::Unix; my $dt = DateTime::Format::Epoch::Unix->parse_datetime( 1051488000 ); # 2003-04-28T00:00:00...
17.41 KB  
Libraries  -  DateTime::Format::Epoch::MacOS 0.10
DateTime::Format::Epoch::MacOS is a Perl module that can convert DateTimes to/from Mac OS epoch seconds. SYNOPSIS use DateTime::Format::Epoch::MacOS; my $dt = DateTime::Format::Epoch::MacOS->parse_datetime( 1051488000 );...
17.41 KB  
Libraries  -  DateTime::Format::Epoch::RJD 0.10
DateTime::Format::Epoch::RJD is a Perl module that can convert DateTimes to/from Reduced Julian Days. SYNOPSIS use DateTime::Format::Epoch::RJD; my $dt = DateTime::Format::Epoch::RJD->parse_datetime( 53244.5 ); # 2004-08-27T00:00:00...
17.41 KB  
Libraries  -  DateTime::Format::Epoch::Lilian 0.10
DateTime::Format::Epoch::Lilian is a Perl module to convert DateTimes to/from Lilian Days. SYNOPSIS use DateTime::Format::Epoch::Lilian; my $dt = DateTime::Format::Epoch::Lilian->parse_datetime( 53244.5 ); # 2004-08-27T00:00:00...
17.41 KB  
Libraries  -  DateTime::Format::Epoch::RataDie 0.10
DateTime::Format::Epoch::RataDie is a Perl module that can convert DateTimes to/from Rata Die. SYNOPSIS use DateTime::Format::Epoch::RataDie; my $dt = DateTime::Format::Epoch::RataDie->parse_datetime( $count );...
17.41 KB  
Libraries  -  DateTime::Format::Epoch::MJD 0.10
DateTime::Format::Epoch::MJD is a Perl module that can convert DateTimes to/from Modified Julian Days. SYNOPSIS use DateTime::Format::Epoch::MJD; my $dt = DateTime::Format::Epoch::MJD->parse_datetime( 53244 ); # 2004-08-27T00:00:00...
17.41 KB  
NEW DOWNLOADS IN PROGRAMMING, LIBRARIES
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  Math::GMPf 0.29
Math::GMPf - perl interface to the GMP library's floating point (mpf) functions.
30.72 KB  
Programming  -  Net::Wire10 1.08
Net::Wire10 is a Pure Perl connector that talks to Sphinx, MySQL and Drizzle servers. Net::Wire10 implements the low-level network protocol, alias the MySQL wire protocol version 10, necessary for talking to one of the aforementioned...
30.72 KB  
Programming  -  logilab-common 0.56.2
a bunch of modules providing low level functionnalities shared among some python projects devel Please note that some of the modules have some extra dependencies. For instance, logilab.common.db will require a db-api 2.0 compliant...
174.08 KB  
Programming  -  OpenSSL for linux 1.0.0a
The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a...
3.83 MB  
Libraries  -  wolfSSL 4.0.0
The wolfSSL embedded SSL/TLS library is a lightweight SSL library written in ANSI standard C and targeted for embedded and RTOS environments - primarily because of its small size, speed, and feature set. It is commonly used in standard operating...
3.88 MB  
Libraries  -  EuGTK 4.8.9
Makes it easy to develop good- looking, fast, cross-platform programs that run on Linux, OS X, and Windows. Euphoria is a very fast interpreted/compiled language with straight-forward syntax. EuGTK allows programming in a clean, object-oriented...
10.68 MB  
Libraries  -  Linux User Group Library Manager 1.0
The LUG Library Manager is a project to help Linux User Groups start their own library. A LUG library is helpful to the community at large because it increases access to information, and gives everyone the opportunity to become more knowledgeable.
5.35 KB  
Libraries  -  Module::MakefilePL::Parse 0.12
Module::MakefilePL::Parse is a Perl module to parse required modules from Makefile.PL. SYNOPSIS use Module::MakefilePL::Parse; open $fh, Makefile.PL; $parser = Module::MakefilePL::Parse->new( join("", ) ); $info = $parser->required;...
8.19 KB  
Libraries  -  sqlpp 0.06
sqlpp Perl package is a SQL preprocessor. sqlpp is a conventional cpp-alike preprocessor taught to understand SQL ( PgSQL, in particular) syntax specificities. In addition to the standard #define/#ifdef/#else/#endif cohort, provides also...
10.24 KB