.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Format::Human::Bytes 3pm" .TH Format::Human::Bytes 3pm "2021-01-05" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Format::Human::Bytes \- Format a bytecount and make it human readable .SH "VERSION" .IX Header "VERSION" Version 0.06 .SH "SYNOPSIS" .IX Header "SYNOPSIS" Ever showed 12345678 bytes to the user instead of just saying 11MB? This module returns you a printable string which is more readable by humans than a simple bytecount. .PP .Vb 1 \& use Format::Human::Bytes; \& \& $readable = Format::Human::Bytes::base2($bytecount[,$decimals]); \& $readable = Format::Human::Bytes::base10($bytecount[,$decimals]); \& \& $readable = Format::Human::Bytes\->base2($bytecount[,$decimals]); \& $readable = Format::Human::Bytes\->base10($bytecount[,$decimals]); \& \& my $fhb = Format::Human::Bytes\->new(); \& $readable = $fhb\->base2($bytecount[,$decimals]); \& $readable = $fhb\->base10($bytecount[,$decimals]); .Ve .PP All functions do \*(L"intelligent\*(R" switching to the next unit, for example: .PP .Vb 4 \& 1000 => 1000B \& [...] \& 8000 => 8000B \& 9000 => 9kB .Ve .PP The difference between 1000 bytes and 1500 bytes is usually bigger (for example because of a slow link) than between 95kB and 95,5kB. The same applies to 8000kB vs. 9 \s-1MB\s0 and for the other units. .PP Depending on your usage, you may want to specify how many decimals should be shown (defaults to no decimals). .SH "FUNCTIONS / METHODS" .IX Header "FUNCTIONS / METHODS" .SS "new" .IX Subsection "new" .Vb 1 \& my $fhb = Format::Human::Bytes\->new(); .Ve .PP Creates and returns a Format::Human::Bytes \- object. .SS "base2" .IX Subsection "base2" Callable as a function: .PP .Vb 1 \& $readable = Format::Human::Bytes::base2($bytecount[,$decimals]); .Ve .PP Callable as a class method: .PP .Vb 1 \& $readable = Format::Human::Bytes\->base2($bytecount[,$decimals]); .Ve .PP Callable as a object method: .PP .Vb 1 \& $readable = $fhb\->base2($bytecount[,$decimals]); .Ve .PP Returns the correct readable form of the given bytecount. .PP Correct in this case means that 1kB are 1024 Bytes which is how computers see the world. .PP If you specify a decimal parameter, the result number will have the number of decimal numbers you specified. .SS "base10" .IX Subsection "base10" Callable as a function: .PP .Vb 1 \& $readable = Format::Human::Bytes::base10($bytecount[,$decimals]); .Ve .PP Callable as a class method: .PP .Vb 1 \& $readable = Format::Human::Bytes\->base10($bytecount[,$decimals]); .Ve .PP Callable as a object method: .PP .Vb 1 \& $readable = $fhb\->base10($bytecount[,$decimals]); .Ve .PP Returns the incorrect readable form of the given bytecount. .PP Incorrect in this case means that 1kB is 1000 Bytes and 1 \s-1MB\s0 is 1000000 bytes which is how some (many) people see the world, but it's wrong for computers. .PP If you specify a decimal parameter, the result number will have the number of decimal numbers you specified. .SH "AUTHOR" .IX Header "AUTHOR" Sebastian Willing, \f(CW\*(C`\*(C'\fR .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \f(CW\*(C`bug\-format\-human\-bytes at rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .SH "SUPPORT" .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc Format::Human::Bytes .Ve .PP You can also look for information at: .IP "\(bu" 4 \&\s-1RT: CPAN\s0's request tracker .Sp .IP "\(bu" 4 AnnoCPAN: Annotated \s-1CPAN\s0 documentation .Sp .IP "\(bu" 4 \&\s-1CPAN\s0 Ratings .Sp .IP "\(bu" 4 Search \s-1CPAN\s0 .Sp .SH "HISTORY" .IX Header "HISTORY" The functions are in use since late 2003 or early 2004 but I didn't pack them for \s-1CPAN\s0 before 2009. .SH "LICENSE" .IX Header "LICENSE" This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.