NAME

cs::Units - simple units conversions


SYNOPSIS

use cs::Units;

$elapsed = cs::Units::sec2human(3);

$storage = cs::Units::bytes2human();

$count = cs::Units::num2human(2);

@dec = cs::Units::decompose($somevalue, \@unitsTbale, $count);


DESCRIPTION

This module implements a simple decomposition of numbers into human friendly subunits.


GENERAL FUNCTIONS

decompose(value,units,count)

Return the decomposition of the supplied value into subunits based on the table supplied in the arrayref units using at most count subdivisions (default 2). In an array context returns an array of (n1,ab1, n2,ab2, ...) where n1 is the number of units of size 1 with abbrevation ab1 and so forth, from largest units to smallest. In a scalar context returns the concatenation of this array.

sec2human(seconds,count)

Convenience routine calling decompose(secs,\@cs::Units::TimeUnits,count).

bytes2human(bytes,count)

Convenience routine calling decompose(bytes,\@cs::Units::StorageUnits,count).

num2human(number,count)

Convenience routine calling decompose(number,\@cs::Units::SizeUnits,count).


AUTHOR

Cameron Simpson <cs@zip.com.au>