NAME
Number::Format::FitWidth - Pad all number(s) to the same width that will fit the widest number
VERSION
This document describes version 0.002 of Number::Format::FitWidth (from Perl distribution Number-Format-FitWidth), released on 2026-06-26.
SYNOPSIS
use Number::Format::FitWidth qw(format_fitwidth);
format_fitwidth(1, 2, 10, 12); # => (" 1", " 2", "10", "12")
format_fitwidth(1, 10, 100); # => (" 1", " 10", "100")
# zero_prefix option
format_fitwidth({zero_prefix=>1}, 1, 10, 100); # => ("001", "010", "100")
# max option
format_fitwidth({max=>9999}, 1); # => (" 1")
# TODO: decimals, negative number
# TODO: thousands_sep option
# TODO: decimal_point option
# TODO: decimal_digits option
DESCRIPTION
FUNCTIONS
format_fitwidth
This is basically a glorified sprintf() which will determine the width for you. There are some conveniences (some not yet implemented) e.g. handling decimal numbers, negative numbers, specifying maximum and minimum instead of getting from the arguments, etc.
Usage:
@formatted = format_fitwidth( [ \%opts, ] @numbers)
Options:
max
zero_prefix
Boolean.
HOMEPAGE
Please visit the project's homepage at https://metacpan.org/release/Number-Format-FitWidth.
SOURCE
Source repository is at https://github.com/perlancar/perl-Number-Format-FitWidth.
SEE ALSO
Other Number::Format::* modules.
AUTHOR
perlancar <perlancar@cpan.org>
CONTRIBUTOR
perlancar <perlancar@gmail.com>
CONTRIBUTING
To contribute, you can send patches by email/via RT, or send pull requests on GitHub.
Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by perlancar <perlancar@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
BUGS
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Number-Format-FitWidth
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.