.\" 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 3pm" .TH Format 3pm "2020-12-28" "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" Number::Format \- Perl extension for formatting numbers .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 9 \& use Number::Format; \& my $x = new Number::Format %args; \& $formatted = $x\->round($number, $precision); \& $formatted = $x\->format_number($number, $precision, $trailing_zeroes); \& $formatted = $x\->format_negative($number, $picture); \& $formatted = $x\->format_picture($number, $picture); \& $formatted = $x\->format_price($number, $precision, $symbol); \& $formatted = $x\->format_bytes($number, $precision); \& $number = $x\->unformat_number($formatted); \& \& use Number::Format qw(:subs); \& $formatted = round($number, $precision); \& $formatted = format_number($number, $precision, $trailing_zeroes); \& $formatted = format_negative($number, $picture); \& $formatted = format_picture($number, $picture); \& $formatted = format_price($number, $precision, $symbol); \& $formatted = format_bytes($number, $precision); \& $number = unformat_number($formatted); .Ve .SH "REQUIRES" .IX Header "REQUIRES" Perl, version 5.8 or higher. .PP \&\s-1POSIX\s0.pm to determine locale settings. .PP Carp.pm is used for some error reporting. .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions provide an easy means of formatting numbers in a manner suitable for displaying to the user. .PP There are two ways to use this package. One is to declare an object of type Number::Format, which you can think of as a formatting engine. The various functions defined here are provided as object methods. The constructor \f(CW\*(C`new()\*(C'\fR can be used to set the parameters of the formatting engine. Valid parameters are: .PP .Vb 10 \& THOUSANDS_SEP \- character inserted between groups of 3 digits \& DECIMAL_POINT \- character separating integer and fractional parts \& MON_THOUSANDS_SEP \- like THOUSANDS_SEP, but used for format_price \& MON_DECIMAL_POINT \- like DECIMAL_POINT, but used for format_price \& INT_CURR_SYMBOL \- character(s) denoting currency (see format_price()) \& DECIMAL_DIGITS \- number of digits to the right of dec point (def 2) \& DECIMAL_FILL \- boolean; whether to add zeroes to fill out decimal \& NEG_FORMAT \- format to display negative numbers (def \`\`\-x\*(Aq\*(Aq) \& KILO_SUFFIX \- suffix to add when format_bytes formats kilobytes (trad) \& MEGA_SUFFIX \- " " " " " " megabytes (trad) \& GIGA_SUFFIX \- " " " " " " gigabytes (trad) \& KIBI_SUFFIX \- suffix to add when format_bytes formats kibibytes (iec) \& MEBI_SUFFIX \- " " " " " " mebibytes (iec) \& GIBI_SUFFIX \- " " " " " " gibibytes (iec) .Ve .PP They may be specified in upper or lower case, with or without a leading hyphen ( \- ). .PP If \f(CW\*(C`THOUSANDS_SEP\*(C'\fR is set to the empty string, format_number will not insert any separators. .PP The defaults for \f(CW\*(C`THOUSANDS_SEP\*(C'\fR, \f(CW\*(C`DECIMAL_POINT\*(C'\fR, \&\f(CW\*(C`MON_THOUSANDS_SEP\*(C'\fR, \f(CW\*(C`MON_DECIMAL_POINT\*(C'\fR, and \f(CW\*(C`INT_CURR_SYMBOL\*(C'\fR come from the \s-1POSIX\s0 locale information (see perllocale). If your \&\s-1POSIX\s0 locale does not provide \f(CW\*(C`MON_THOUSANDS_SEP\*(C'\fR and/or \&\f(CW\*(C`MON_DECIMAL_POINT\*(C'\fR fields, then the \f(CW\*(C`THOUSANDS_SEP\*(C'\fR and/or \&\f(CW\*(C`DECIMAL_POINT\*(C'\fR values are used for those parameters. Formerly, \&\s-1POSIX\s0 was optional but this caused problems in some cases, so it is now required. If this causes you hardship, please contact the author of this package at (remove \*(L"\s-1SPAM\*(R"\s0 to get correct email address) for help. .PP If any of the above parameters are not specified when you invoke \&\f(CW\*(C`new()\*(C'\fR, then the values are taken from package global variables of the same name (e.g. \f(CW$DECIMAL_POINT\fR is the default for the \&\f(CW\*(C`DECIMAL_POINT\*(C'\fR parameter). If you use the \f(CW\*(C`:vars\*(C'\fR keyword on your \&\f(CW\*(C`use Number::Format\*(C'\fR line (see non-object-oriented example below) you will import those variables into your namesapce and can assign values as if they were your own local variables. The default values for all the parameters are: .PP .Vb 10 \& THOUSANDS_SEP = \*(Aq,\*(Aq \& DECIMAL_POINT = \*(Aq.\*(Aq \& MON_THOUSANDS_SEP = \*(Aq,\*(Aq \& MON_DECIMAL_POINT = \*(Aq.\*(Aq \& INT_CURR_SYMBOL = \*(AqUSD\*(Aq \& DECIMAL_DIGITS = 2 \& DECIMAL_FILL = 0 \& NEG_FORMAT = \*(Aq\-x\*(Aq \& KILO_SUFFIX = \*(AqK\*(Aq \& MEGA_SUFFIX = \*(AqM\*(Aq \& GIGA_SUFFIX = \*(AqG\*(Aq \& KIBI_SUFFIX = \*(AqKiB\*(Aq \& MEBI_SUFFIX = \*(AqMiB\*(Aq \& GIBI_SUFFIX = \*(AqGiB\*(Aq .Ve .PP Note however that when you first call one of the functions in this module \fIwithout\fR using the object-oriented interface, further setting of those global variables will have no effect on non-OO calls. It is recommended that you use the object-oriented interface instead for fewer headaches and a cleaner design. .PP The \f(CW\*(C`DECIMAL_FILL\*(C'\fR and \f(CW\*(C`DECIMAL_DIGITS\*(C'\fR values are not set by the Locale system, but are definable by the user. They affect the output of \f(CW\*(C`format_number()\*(C'\fR. Setting \f(CW\*(C`DECIMAL_DIGITS\*(C'\fR is like giving that value as the \f(CW$precision\fR argument to that function. Setting \&\f(CW\*(C`DECIMAL_FILL\*(C'\fR to a true value causes \f(CW\*(C`format_number()\*(C'\fR to append zeroes to the right of the decimal digits until the length is the specified number of digits. .PP \&\f(CW\*(C`NEG_FORMAT\*(C'\fR is only used by \f(CW\*(C`format_negative()\*(C'\fR and is a string containing the letter 'x', where that letter will be replaced by a positive representation of the number being passed to that function. \&\f(CW\*(C`format_number()\*(C'\fR and \f(CW\*(C`format_price()\*(C'\fR utilize this feature by calling \f(CW\*(C`format_negative()\*(C'\fR if the number was less than 0. .PP \&\f(CW\*(C`KILO_SUFFIX\*(C'\fR, \f(CW\*(C`MEGA_SUFFIX\*(C'\fR, and \f(CW\*(C`GIGA_SUFFIX\*(C'\fR are used by \&\f(CW\*(C`format_bytes()\*(C'\fR when the value is over 1024, 1024*1024, or 1024*1024*1024, respectively. The default values are \*(L"K\*(R", \*(L"M\*(R", and \&\*(L"G\*(R". These apply in the default \*(L"traditional\*(R" mode only. Note: \s-1TERA\s0 or higher are not implemented because of integer overflows on 32\-bit systems. .PP \&\f(CW\*(C`KIBI_SUFFIX\*(C'\fR, \f(CW\*(C`MEBI_SUFFIX\*(C'\fR, and \f(CW\*(C`GIBI_SUFFIX\*(C'\fR are used by \&\f(CW\*(C`format_bytes()\*(C'\fR when the value is over 1024, 1024*1024, or 1024*1024*1024, respectively. The default values are \*(L"KiB\*(R", \*(L"MiB\*(R", and \*(L"GiB\*(R". These apply in the \*(L"iso60027\*(R"" mode only. Note: \s-1TEBI\s0 or higher are not implemented because of integer overflows on 32\-bit systems. .PP The only restrictions on \f(CW\*(C`DECIMAL_POINT\*(C'\fR and \f(CW\*(C`THOUSANDS_SEP\*(C'\fR are that they must not be digits and must not be identical. There are no restrictions on \f(CW\*(C`INT_CURR_SYMBOL\*(C'\fR. .PP For example, a German user might include this in their code: .PP .Vb 5 \& use Number::Format; \& my $de = new Number::Format(\-thousands_sep => \*(Aq.\*(Aq, \& \-decimal_point => \*(Aq,\*(Aq, \& \-int_curr_symbol => \*(AqDEM\*(Aq); \& my $formatted = $de\->format_number($number); .Ve .PP Or, if you prefer not to use the object oriented interface, you can do this instead: .PP .Vb 5 \& use Number::Format qw(:subs :vars); \& $THOUSANDS_SEP = \*(Aq.\*(Aq; \& $DECIMAL_POINT = \*(Aq,\*(Aq; \& $INT_CURR_SYMBOL = \*(AqDEM\*(Aq; \& my $formatted = format_number($number); .Ve .SH "EXPORTS" .IX Header "EXPORTS" Nothing is exported by default. To export the functions or the global variables defined herein, specify the function name(s) on the import list of the \f(CW\*(C`use Number::Format\*(C'\fR statement. To export all functions defined herein, use the special tag \f(CW\*(C`:subs\*(C'\fR. To export the variables, use the special tag \f(CW\*(C`:vars\*(C'\fR; to export both subs and vars you can use the tag \f(CW\*(C`:all\*(C'\fR. .SH "METHODS" .IX Header "METHODS" .ie n .IP "new( %args )" 4 .el .IP "new( \f(CW%args\fR )" 4 .IX Item "new( %args )" Creates a new Number::Format object. Valid keys for \f(CW%args\fR are any of the parameters described above. Keys may be in all uppercase or all lowercase, and may optionally be preceded by a hyphen (\-) character. Example: .Sp .Vb 3 \& my $de = new Number::Format(\-thousands_sep => \*(Aq.\*(Aq, \& \-decimal_point => \*(Aq,\*(Aq, \& \-int_curr_symbol => \*(AqDEM\*(Aq); .Ve .ie n .IP "round($number, $precision)" 4 .el .IP "round($number, \f(CW$precision\fR)" 4 .IX Item "round($number, $precision)" Rounds the number to the specified precision. If \f(CW$precision\fR is omitted, the value of the \f(CW\*(C`DECIMAL_DIGITS\*(C'\fR parameter is used (default value 2). Both input and output are numeric (the function uses math operators rather than string manipulation to do its job), The value of \&\f(CW$precision\fR may be any integer, positive or negative. Examples: .Sp .Vb 4 \& round(3.14159) yields 3.14 \& round(3.14159, 4) yields 3.1416 \& round(42.00, 4) yields 42 \& round(1234, \-2) yields 1200 .Ve .Sp Since this is a mathematical rather than string oriented function, there will be no trailing zeroes to the right of the decimal point, and the \f(CW\*(C`DECIMAL_POINT\*(C'\fR and \f(CW\*(C`THOUSANDS_SEP\*(C'\fR variables are ignored. To format your number using the \f(CW\*(C`DECIMAL_POINT\*(C'\fR and \f(CW\*(C`THOUSANDS_SEP\*(C'\fR variables, use \f(CW\*(C`format_number()\*(C'\fR instead. .ie n .IP "format_number($number, $precision, $trailing_zeroes)" 4 .el .IP "format_number($number, \f(CW$precision\fR, \f(CW$trailing_zeroes\fR)" 4 .IX Item "format_number($number, $precision, $trailing_zeroes)" Formats a number by adding \f(CW\*(C`THOUSANDS_SEP\*(C'\fR between each set of 3 digits to the left of the decimal point, substituting \f(CW\*(C`DECIMAL_POINT\*(C'\fR for the decimal point, and rounding to the specified precision using \&\f(CW\*(C`round()\*(C'\fR. Note that \f(CW$precision\fR is a \fImaximum\fR precision specifier; trailing zeroes will only appear in the output if \&\f(CW$trailing_zeroes\fR is provided, or the parameter \f(CW\*(C`DECIMAL_FILL\*(C'\fR is set, with a value that is true (not zero, undef, or the empty string). If \f(CW$precision\fR is omitted, the value of the \f(CW\*(C`DECIMAL_DIGITS\*(C'\fR parameter (default value of 2) is used. .Sp If the value is too large or great to work with as a regular number, but instead must be shown in scientific notation, returns that number in scientific notation without further formatting. .Sp Examples: .Sp .Vb 7 \& format_number(12345.6789) yields \*(Aq12,345.68\*(Aq \& format_number(123456.789, 2) yields \*(Aq123,456.79\*(Aq \& format_number(1234567.89, 2) yields \*(Aq1,234,567.89\*(Aq \& format_number(1234567.8, 2) yields \*(Aq1,234,567.8\*(Aq \& format_number(1234567.8, 2, 1) yields \*(Aq1,234,567.80\*(Aq \& format_number(1.23456789, 6) yields \*(Aq1.234568\*(Aq \& format_number("0.000020000E+00", 7);\*(Aq yields \*(Aq2e\-05\*(Aq .Ve .Sp Of course the output would have your values of \f(CW\*(C`THOUSANDS_SEP\*(C'\fR and \&\f(CW\*(C`DECIMAL_POINT\*(C'\fR instead of ',' and '.' respectively. .ie n .IP "format_negative($number, $picture)" 4 .el .IP "format_negative($number, \f(CW$picture\fR)" 4 .IX Item "format_negative($number, $picture)" Formats a negative number. Picture should be a string that contains the letter \f(CW\*(C`x\*(C'\fR where the number should be inserted. For example, for standard negative numbers you might use ``\f(CW\*(C`\-x\*(C'\fR'', while for accounting purposes you might use ``\f(CW\*(C`(x)\*(C'\fR''. If the specified number begins with a ``\-'' character, that will be removed before formatting, but formatting will occur whether or not the number is negative. .ie n .IP "format_picture($number, $picture)" 4 .el .IP "format_picture($number, \f(CW$picture\fR)" 4 .IX Item "format_picture($number, $picture)" Returns a string based on \f(CW$picture\fR with the \f(CW\*(C`#\*(C'\fR characters replaced by digits from \f(CW$number\fR. If the length of the integer part of \f(CW$number\fR is too large to fit, the \f(CW\*(C`#\*(C'\fR characters are replaced with asterisks (\f(CW\*(C`*\*(C'\fR) instead. Examples: .Sp .Vb 5 \& format_picture(100.023, \*(AqUSD ##,###.##\*(Aq) yields \*(AqUSD 100.02\*(Aq \& format_picture(1000.23, \*(AqUSD ##,###.##\*(Aq) yields \*(AqUSD 1,000.23\*(Aq \& format_picture(10002.3, \*(AqUSD ##,###.##\*(Aq) yields \*(AqUSD 10,002.30\*(Aq \& format_picture(100023, \*(AqUSD ##,###.##\*(Aq) yields \*(AqUSD **,***.**\*(Aq \& format_picture(1.00023, \*(AqUSD #.###,###\*(Aq) yields \*(AqUSD 1.002,300\*(Aq .Ve .Sp The comma (,) and period (.) you see in the picture examples should match the values of \f(CW\*(C`THOUSANDS_SEP\*(C'\fR and \f(CW\*(C`DECIMAL_POINT\*(C'\fR, respectively, for proper operation. However, the \f(CW\*(C`THOUSANDS_SEP\*(C'\fR characters in \f(CW$picture\fR need not occur every three digits; the \&\fIonly\fR use of that variable by this function is to remove leading commas (see the first example above). There may not be more than one instance of \f(CW\*(C`DECIMAL_POINT\*(C'\fR in \f(CW$picture\fR. .Sp The value of \f(CW\*(C`NEG_FORMAT\*(C'\fR is used to determine how negative numbers are displayed. The result of this is that the output of this function my have unexpected spaces before and/or after the number. This is necessary so that positive and negative numbers are formatted into a space the same size. If you are only using positive numbers and want to avoid this problem, set \s-1NEG_FORMAT\s0 to \*(L"x\*(R". .ie n .IP "format_price($number, $precision, $symbol)" 4 .el .IP "format_price($number, \f(CW$precision\fR, \f(CW$symbol\fR)" 4 .IX Item "format_price($number, $precision, $symbol)" Returns a string containing \f(CW$number\fR formatted similarly to \&\f(CW\*(C`format_number()\*(C'\fR, except that the decimal portion may have trailing zeroes added to make it be exactly \f(CW$precision\fR characters long, and the currency string will be prefixed. .Sp The \f(CW$symbol\fR attribute may be one of \*(L"\s-1INT_CURR_SYMBOL\*(R"\s0 or \&\*(L"\s-1CURRENCY_SYMBOL\*(R"\s0 (case insensitive) to use the value of that attribute of the object, or a string containing the symbol to be used. The default is \*(L"\s-1INT_CURR_SYMBOL\*(R"\s0 if this argument is undefined or not given; if set to the empty string, or if set to undef and the \&\f(CW\*(C`INT_CURR_SYMBOL\*(C'\fR attribute of the object is the empty string, no currency will be added. .Sp If \f(CW$precision\fR is not provided, the default of 2 will be used. Examples: .Sp .Vb 3 \& format_price(12.95) yields \*(AqUSD 12.95\*(Aq \& format_price(12) yields \*(AqUSD 12.00\*(Aq \& format_price(12, 3) yields \*(Aq12.000\*(Aq .Ve .Sp The third example assumes that \f(CW\*(C`INT_CURR_SYMBOL\*(C'\fR is the empty string. .ie n .IP "format_bytes($number, %options)" 4 .el .IP "format_bytes($number, \f(CW%options\fR)" 4 .IX Item "format_bytes($number, %options)" .PD 0 .ie n .IP "format_bytes($number, $precision) # deprecated" 4 .el .IP "format_bytes($number, \f(CW$precision\fR) # deprecated" 4 .IX Item "format_bytes($number, $precision) # deprecated" .PD Returns a string containing \f(CW$number\fR formatted similarly to \&\f(CW\*(C`format_number()\*(C'\fR, except that large numbers may be abbreviated by adding a suffix to indicate 1024, 1,048,576, or 1,073,741,824 bytes. Suffix may be the traditional K, M, or G (default); or the \s-1IEC\s0 standard 60027 \*(L"KiB,\*(R" \*(L"MiB,\*(R" or \*(L"GiB\*(R" depending on the \*(L"mode\*(R" option. .Sp Negative values will result in an error. .Sp The second parameter can be either a hash that sets options, or a number. Using a number here is deprecated and will generate a warning; early versions of Number::Format only allowed a numeric value. A future release of Number::Format will change this warning to an error. New code should use a hash instead to set options. If it is a number this sets the value of the \*(L"precision\*(R" option. .Sp Valid options are: .RS 4 .IP "precision" 4 .IX Item "precision" Set the precision for displaying numbers. If not provided, a default of 2 will be used. Examples: .Sp .Vb 6 \& format_bytes(12.95) yields \*(Aq12.95\*(Aq \& format_bytes(12.95, precision => 0) yields \*(Aq13\*(Aq \& format_bytes(2048) yields \*(Aq2K\*(Aq \& format_bytes(2048, mode => "iec") yields \*(Aq2KiB\*(Aq \& format_bytes(9999999) yields \*(Aq9.54M\*(Aq \& format_bytes(9999999, precision => 1) yields \*(Aq9.5M\*(Aq .Ve .IP "unit" 4 .IX Item "unit" Sets the default units used for the results. The default is to determine this automatically in order to minimize the length of the string. In other words, numbers greater than or equal to 1024 (or other number given by the 'base' option, q.v.) will be divided by 1024 and \f(CW$KILO_SUFFIX\fR or \f(CW$KIBI_SUFFIX\fR added; if greater than or equal to 1048576 (1024*1024), it will be divided by 1048576 and \&\f(CW$MEGA_SUFFIX\fR or \f(CW$MEBI_SUFFIX\fR appended to the end; etc. .Sp However if a value is given for \f(CW\*(C`unit\*(C'\fR it will use that value instead. The first letter (case-insensitive) of the value given indicates the threshhold for conversion; acceptable values are G (for giga/gibi), M (for mega/mebi), K (for kilo/kibi), or A (for automatic, the default). For example: .Sp .Vb 2 \& format_bytes(1048576, unit => \*(AqK\*(Aq) yields \*(Aq1,024K\*(Aq \& instead of \*(Aq1M\*(Aq .Ve .Sp Note that the valid values to this option do not vary even when the suffix configuration variables have been changed. .IP "base" 4 .IX Item "base" Sets the number at which the \f(CW$KILO_SUFFIX\fR is added. Default is 1024. Set to any value; the only other useful value is probably 1000, as hard disk manufacturers use that number to make their disks sound bigger than they really are. .Sp If the mode (see below) is set to \*(L"iec\*(R" or \*(L"iec60027\*(R" then setting the base option results in an error. .IP "mode" 4 .IX Item "mode" Traditionally, bytes have been given in \s-1SI\s0 (metric) units such as \&\*(L"kilo\*(R" and \*(L"mega\*(R" even though they represent powers of 2 (1024, etc.) rather than powers of 10 (1000, etc.) This \*(L"binary prefix\*(R" causes much confusion in consumer products where \*(L"\s-1GB\*(R"\s0 may mean either 1,048,576 or 1,000,000, for example. The International Electrotechnical Commission has created standard \s-1IEC 60027\s0 to introduce prefixes Ki, Mi, Gi, etc. (\*(L"kibibytes,\*(R" \*(L"mebibytes,\*(R" \&\*(L"gibibytes,\*(R" etc.) to remove this confusion. Specify a mode option with either \*(L"traditional\*(R" or \*(L"iec60027\*(R" (or abbreviate as \*(L"trad\*(R" or \&\*(L"iec\*(R") to indicate which type of binary prefix you want format_bytes to use. For backward compatibility, \*(L"traditional\*(R" is the default. See http://en.wikipedia.org/wiki/Binary_prefix for more information. .RE .RS 4 .RE .IP "unformat_number($formatted)" 4 .IX Item "unformat_number($formatted)" Converts a string as returned by \f(CW\*(C`format_number()\*(C'\fR, \&\f(CW\*(C`format_price()\*(C'\fR, or \f(CW\*(C`format_picture()\*(C'\fR, and returns the corresponding value as a numeric scalar. Returns \f(CW\*(C`undef\*(C'\fR if the number does not contain any digits. Examples: .Sp .Vb 4 \& unformat_number(\*(AqUSD 12.95\*(Aq) yields 12.95 \& unformat_number(\*(AqUSD 12.00\*(Aq) yields 12 \& unformat_number(\*(Aqfoobar\*(Aq) yields undef \& unformat_number(\*(Aq1234\-567@.8\*(Aq) yields 1234567.8 .Ve .Sp The value of \f(CW\*(C`DECIMAL_POINT\*(C'\fR is used to determine where to separate the integer and decimal portions of the input. All other non-digit characters, including but not limited to \f(CW\*(C`INT_CURR_SYMBOL\*(C'\fR and \&\f(CW\*(C`THOUSANDS_SEP\*(C'\fR, are removed. .Sp If the number matches the pattern of \f(CW\*(C`NEG_FORMAT\*(C'\fR \fIor\fR there is a ``\-'' character before any of the digits, then a negative number is returned. .Sp If the number ends with the \f(CW\*(C`KILO_SUFFIX\*(C'\fR, \f(CW\*(C`KIBI_SUFFIX\*(C'\fR, \&\f(CW\*(C`MEGA_SUFFIX\*(C'\fR, \f(CW\*(C`MEBI_SUFFIX\*(C'\fR, \f(CW\*(C`GIGA_SUFFIX\*(C'\fR, or \f(CW\*(C`GIBI_SUFFIX\*(C'\fR characters, then the number returned will be multiplied by the appropriate multiple of 1024 (or if the base option is given, by the multiple of that value) as appropriate. Examples: .Sp .Vb 4 \& unformat_number("4K", base => 1024) yields 4096 \& unformat_number("4K", base => 1000) yields 4000 \& unformat_number("4KiB", base => 1024) yields 4096 \& unformat_number("4G") yields 4294967296 .Ve .SH "CAVEATS" .IX Header "CAVEATS" Some systems, notably OpenBSD, may have incomplete locale support. Using this module together with \fBsetlocale\fR\|(3) in OpenBSD may therefore not produce the intended results. .SH "BUGS" .IX Header "BUGS" No known bugs at this time. Report bugs using the \s-1CPAN\s0 request tracker at or by email to the author. .SH "AUTHOR" .IX Header "AUTHOR" William R. Ward, SwPrAwM@cpan.org (remove \*(L"\s-1SPAM\*(R"\s0 before sending email, leaving only my initials) .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBperl\fR\|(1).