NAME
App::Yath::Plugin::Utilization::Units - Parse number-with-unit strings used by yath options.
SYNOPSIS
use App::Yath::Plugin::Utilization::Units qw/parse_quantity parse_byte_size parse_duration parse_count_or_pct parse_size_or_pct/;
my ($n, $u) = parse_quantity('512mb', units => [qw/kb mb gb tb/]);
my $bytes = parse_byte_size('1gb'); # 1073741824
my $secs = parse_duration('500ms'); # 0.5
EXPORTS
- ($num, $unit) = parse_quantity($raw, %opts)
-
Splits
$rawinto a numeric value and a unit suffix from a caller-supplied list. Whitespace stripped. Croaks on invalid input. - $bytes = parse_byte_size($raw, %opts)
-
Accepts
kb/mb/gb/tb(case-insensitive). Returns integer bytes. - $secs = parse_duration($raw, %opts)
-
Accepts
ms/s/m(case-insensitive). Default units. Returns float seconds. - $result = parse_count_or_pct($raw, %opts)
-
Accepts a bare positive integer or
NUMBER%. Returns{ kind => 'count'|'pct', value => N }. - $result = parse_size_or_pct($raw, %opts)
-
Accepts a byte size (
NUMmb) orNUMBER%. Returns{ kind => 'bytes'|'pct', value => N }. Bare numbers without a unit are rejected unlessdefault_unitis supplied.
SOURCE
The source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/.
MAINTAINERS
AUTHORS
COPYRIGHT
Copyright Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/