Locale::Currency::Format

Locale::Currency::Format contains Perl functions for formatting monetary values.
Download

Locale::Currency::Format Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • tnguyen
  • Publisher web site:
  • http://search.cpan.org/~tnguyen/Locale-Currency-Format-1.23/Format.pm

Locale::Currency::Format Tags


Locale::Currency::Format Description

Locale::Currency::Format contains Perl functions for formatting monetary values. Locale::Currency::Format contains Perl functions for formatting monetary values.SYNOPSIS use Locale::Currency::Format; $amnt = currency_format('usd', 1000); # => 1,000.00 USD $amnt = currency_format('eur', 1000, FMT_COMMON); # => EUR1.000,00 $amnt = currency_format('usd', 1000, FMT_SYMBOL); # => $1,000.00 $sym = currency_symbol('usd'); # => $ $sym = currency_symbol('gbp', SYM_HTML); # => The following example illustrates how to use Locale::Currency::Format with Mason. Skip it if you are not interested in Mason. A simple Mason component might look like this: Total: < % 123456789, 'eur' |c % > < %init > use Locale::Currency::Format; $m->interp->set_escape(c => &escape_currency); sub escape_currency { my ($amnt, $code) = ${$_} =~ /(.*?)({3})/; ${$_} = currency_format($code, $amnt, FMT_HTML); } < /%init >Locale::Currency::Format is a light-weight Perl module that allows one to display monetary values in the formats recognized internationally or locally depending on his wish.currency_format(CODE, AMOUNT )currency_format takes two mandatory parameters, namely currency code and amount respectively, and optionally a third parameter indicating which format is desired. Upon failure, it returns undef and an error message is stored in $Locale::Currency::Format::error. CODE - A 3-letter currency code as specified in ISO 4217. Note that old code such as GBP, FRF and so on can also be valid. AMOUNT - A numeric value. FORMAT - There are five different format options FMT_STANDARD, FMT_COMMON, FMT_SYMBOL, FMT_HTML and FMT_NAME. If it is omitted, the default format is FMT_STANDARD. FMT_STANDARD Ex: 1,000.00 USD FMT_SYMBOL Ex: $1,000.00 FMT_COMMON Ex: 1.000 Dong (Vietnam), BEF 1.000 (Belgium) FMT_HTML Ex: 1,000.00 (pound-sign HTML escape) FMT_NAME Ex: 1,000.00 US Dollar By default the trailing zeros after the decimal point will be added. To turn it off, do a bitwise B of FMT_NOZEROS with one of the five options above. Ex: FMT_STANDARD | FMT_NOZEROS will give 1,000 USDcurrency_symbol(CODE )For conveniences, the function currency_symbol is provided for symbol lookup given a 3-letter currency code. Optionally, one can specify which format the symbol should be returned - Unicode-based character or HTML escape. Default is a Unicode-based character. Upon failure, it returns undef and an error message is stored in $Locale::Currency::Format::error. CODE - A 3-letter currency code as specified in ISO 4217 TYPE - There are two available types SYM_UTF and SYM_HTML SYM_UTF returns the symbol (if exists) as an Unicode character SYM_HTML returns the symbol (if exists) as a HTML escape Requirements: · Perl


Locale::Currency::Format Related Software