Skip to content

billward/number-format-perl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Number::Format - Convert numbers to strings with pretty formatting

WHAT IS IT

Number::Format is a library for formatting numbers. Functions are provided for converting numbers to strings in a variety of ways, and to convert strings that contain numbers back into numeric form. The output formats may include thousands separators - characters inserted between each group of three characters counting right to left from the decimal point. The characters used for the decimal point and the thousands separator come from the locale information or can be specified by the user.

Also of note is the format_picture command which converts a number into a string using a "picture" string that you provide. This is similar to the PRINT USING statement that some versions of BASIC have.

In addition, functions exist to generate strings for numbers containing currency (e.g. "USD 9.99", "DEM 20.00", etc.) or for rounding large values of bytes to the nearest giga/mega/kilo (e.g. "1.5M", "640K", etc.).

ALSO AVAILABLE

If you enjoy this module check out the following related projects:

  • Template Toolkit users: Use Template::Plugin::Number::Format (contributed by Darren Chamberlain) from your templates.
  • JavaScript users: we also have a JavaScript translation of the Number::Format done by Cees Hek. Find that on Github here: http://number-format.cvs.sourceforge.net/

HOW TO GET

Download it from your favorite CPAN mirror, or from the Sourceforge project: https://github.com/billward/number-format-perl/

If you are interested in being a developer for this project, or for more information, please contact William R. Ward, [email protected] (remove "SPAM" before sending email, leaving only my initials).

BUILDING/INSTALLING

Perl version 5.8 or higher is required, though it may work on older versions if you edit the 'require 5.008' line. This package is set up to configure and build like a typical Perl extension. To build:

    perl Makefile.PL
    make
make test
    make install

NOTE: This installs the files in your core Perl module area, typically /usr/local/lib/perl on Unix/Linux and C:\PERL\LIB on Windows, so you may need super-user (root/administrator) access to install. If you wish to install in a private area, such as your home directory, specify that as "perl Makefile.PL PREFIX=/path/to/private/area" and it will be installed there instead.

PROBLEMS/BUG REPORTS

Please submit your issues via the CPAN RT bug tracker or on github http://rt.cpan.org/NoAuth/Bugs.html?Dist=Number-Format https://github.com/billward/number-format-perl/

Please check for existing reports on your issue in both places before filing a new bug.

CREDITS AND LICENSES

This package is copyright 1997-2015 by William R. Ward et al., and may be distributed under the same terms as cover Perl itself (your choice of Artistic or GPL). See http://dev.perl.org/licenses/ for more information.

CHANGES

See the file "CHANGES" for a description of the changes with each version of Number::Format or browse history in git.

About

Number::Format Perl Module

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages