Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    Locale::Currency::Format 1.23

    Download button

    No screenshots available
    Downloads: 388  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Fair (2.7/5)
    13 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    tnguyen | More programs
    Perl Artistic License / FREE
    February 19th, 2008, 15:53 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    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) = ${$_[0]} =~ /(.*?)([A-Za-z]{3})/;
    ${$_[0]} = 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 [, FORMAT])

    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 USD
    currency_symbol(CODE [, TYPE])

    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

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    Perl functions | monetary values | Perl module | currency | Perl | functions

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM