Format...:Bytes(3pm)
π Format::Human::Bytes β the manual, but make it cute π
okay bestie, so this is Format::Human::Bytes, a little Perl module that lives in the User Contributed Perl Documentation section of the manual. She's on version 0.06 and honestly? she's iconic. Let's get into it. π¦
β¨ NAME β¨
Format::Human::Bytes β format a bytecount and make it human readable π
Like, the whole point. Bytes in, vibes out.
πΈ VERSION πΈ
Version 0.06. periodt.
π SYNOPSIS π
Ever showed 12345678 bytes to a user instead of just saying 11MB?? π Not the move. This module hands you back a printable string that actual humans can read, instead of a raw bytecount screaming for help.
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]);
All the functions do an "intelligent" switch to the next unit when it's time, like:
1000 => 1000B
[...]
8000 => 8000B
9000 => 9kB
The way that the difference between 1000 bytes and 1500 bytes usually hits way harder (say, because of a slow link) than the difference between 95kB and 95,5kB?? Yeah. Same energy applies to 8000kB vs. 9 MB and to all the other units. π₯
Depending on how you're using this, you might wanna say how many decimals you want shown β and heads up, it defaults to no decimals. π
π«Ά FUNCTIONS / METHODS π«Ά
π new
my $fhb = Format::Human::Bytes->new();
Creates and returns a Format::Human::Bytes object. That's it, that's the whole job. She's lowkey just here to exist. β¨
π base2
Callable as a function:
$readable = Format::Human::Bytes::base2($bytecount[,$decimals]);
Callable as a class method:
$readable = Format::Human::Bytes->base2($bytecount[,$decimals]);
Callable as an object method:
$readable = $fhb->base2($bytecount[,$decimals]);
Returns the correct readable form of the bytecount you gave it.
"Correct" here means 1kB is 1024 Bytes β which is literally how computers see the world. π
If you pass a decimal parameter, the resulting number will have exactly the number of decimal numbers you specified.
π¦ base10
Callable as a function:
$readable = Format::Human::Bytes::base10($bytecount[,$decimals]);
Callable as a class method:
$readable = Format::Human::Bytes->base10($bytecount[,$decimals]);
Callable as an object method:
$readable = $fhb->base10($bytecount[,$decimals]);
Returns the incorrect readable form of the bytecount you gave it. π
"Incorrect" here means 1kB is 1000 Bytes and 1 MB is 1000000 bytes β which is how some (many) people see the world, but it's wrong for computers. not me exposing the entire metric system π
If you pass a decimal parameter, the resulting number will have exactly the number of decimal numbers you specified.
π AUTHOR π
Sebastian Willing, "<sewi at cpan.org>" β the icon who wrote this, we stan π«Ά
π BUGS π
Please report any bugs or feature requests to "bug-format-human-bytes at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Format-Human-Bytes>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. fr fr, they'll ping you back. π¬
π SUPPORT π
You can find documentation for this module with the perldoc command.
perldoc Format::Human::Bytes
You can also look for information at:
- RT: CPAN's request tracker
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Format-Human-Bytes>
- AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/Format-Human-Bytes>
- CPAN Ratings
<http://cpanratings.perl.org/d/Format-Human-Bytes>
- Search CPAN
<http://search.cpan.org/dist/Format-Human-Bytes/>
β HISTORY β
The functions are in use since late 2003 or early 2004 but I didn't pack them for CPAN before 2009. two-thousand-late-2003?? she was serving before she even had a CPAN release, main character energy honestly π
π LICENSE π
This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself. slay. π
okay that's the whole page bestie, go format some bytes and go off β¨
Brought to you by perl v5.34.0 on 2022-06-14 β that's the version and date this page was generated, mwah π
π¦ where this page comes from
- debian bookworm: libformat-human-bytes-perl 0.06-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libformat-human-bytes-perl 0.06-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libformat-human-bytes-perl 0.06-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libformat-human-bytes-perl 0.06-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libformat-human-bytes-perl 0.06-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms