1Format::Human::Bytes(3)User Contributed Perl DocumentatioFnormat::Human::Bytes(3)
2
3
4

NAME

6       Format::Human::Bytes - Format a bytecount and make it human readable
7

VERSION

9       Version 0.06
10

SYNOPSIS

12       Ever showed 12345678 bytes to the user instead of just saying 11MB?
13       This module returns you a printable string which is more readable by
14       humans than a simple bytecount.
15
16           use Format::Human::Bytes;
17
18           $readable = Format::Human::Bytes::base2($bytecount[,$decimals]);
19           $readable = Format::Human::Bytes::base10($bytecount[,$decimals]);
20
21           $readable = Format::Human::Bytes->base2($bytecount[,$decimals]);
22           $readable = Format::Human::Bytes->base10($bytecount[,$decimals]);
23
24           my $fhb = Format::Human::Bytes->new();
25           $readable = $fhb->base2($bytecount[,$decimals]);
26           $readable = $fhb->base10($bytecount[,$decimals]);
27
28       All functions do "intelligent" switching to the next unit, for example:
29
30           1000 => 1000B
31           [...]
32           8000 => 8000B
33           9000 => 9kB
34
35       The difference between 1000 bytes and 1500 bytes is usually bigger (for
36       example because of a slow link) than between 95kB and 95,5kB. The same
37       applies to 8000kB vs. 9 MB and for the other units.
38
39       Depending on your usage, you may want to specify how many decimals
40       should be shown (defaults to no decimals).
41

FUNCTIONS / METHODS

43   new
44           my $fhb = Format::Human::Bytes->new();
45
46       Creates and returns a Format::Human::Bytes - object.
47
48   base2
49       Callable as a function:
50
51           $readable = Format::Human::Bytes::base2($bytecount[,$decimals]);
52
53       Callable as a class method:
54
55           $readable = Format::Human::Bytes->base2($bytecount[,$decimals]);
56
57       Callable as a object method:
58
59           $readable = $fhb->base2($bytecount[,$decimals]);
60
61       Returns the correct readable form of the given bytecount.
62
63       Correct in this case means that 1kB are 1024 Bytes which is how
64       computers see the world.
65
66       If you specify a decimal parameter, the result number will have the
67       number of decimal numbers you specified.
68
69   base10
70       Callable as a function:
71
72           $readable = Format::Human::Bytes::base10($bytecount[,$decimals]);
73
74       Callable as a class method:
75
76           $readable = Format::Human::Bytes->base10($bytecount[,$decimals]);
77
78       Callable as a object method:
79
80           $readable = $fhb->base10($bytecount[,$decimals]);
81
82       Returns the incorrect readable form of the given bytecount.
83
84       Incorrect in this case means that 1kB is 1000 Bytes and 1 MB is 1000000
85       bytes which is how some (many) people see the world, but it's wrong for
86       computers.
87
88       If you specify a decimal parameter, the result number will have the
89       number of decimal numbers you specified.
90

AUTHOR

92       Sebastian Willing, "<sewi at cpan.org>"
93

BUGS

95       Please report any bugs or feature requests to "bug-format-human-bytes
96       at rt.cpan.org", or through the web interface at
97       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Format-Human-Bytes>.  I
98       will be notified, and then you'll automatically be notified of progress
99       on your bug as I make changes.
100

SUPPORT

102       You can find documentation for this module with the perldoc command.
103
104           perldoc Format::Human::Bytes
105
106       You can also look for information at:
107
108       •   RT: CPAN's request tracker
109
110           <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Format-Human-Bytes>
111
112       •   AnnoCPAN: Annotated CPAN documentation
113
114           <http://annocpan.org/dist/Format-Human-Bytes>
115
116       •   CPAN Ratings
117
118           <http://cpanratings.perl.org/d/Format-Human-Bytes>
119
120       •   Search CPAN
121
122           <http://search.cpan.org/dist/Format-Human-Bytes/>
123

HISTORY

125       The functions are in use since late 2003 or early 2004 but I didn't
126       pack them for CPAN before 2009.
127

LICENSE

129       This program is free software; you can redistribute it and/or modify it
130       under the same terms as Perl 5 itself.
131
132
133
134perl v5.32.1                      2021-01-27           Format::Human::Bytes(3)
Impressum