NAME

Locale::Object::Currency - currency information objects

DESCRIPTION

Locale::Object::Country allows you to create objects containing information about countries such as their ISO codes, currencies and so on.

SYNOPSIS

    use Locale::Object::Currency;

    my $usd = Locale::Object::Currency->new( country_code => 'us' );

    my $name           = $usd->name;
    my $code           = $usd->code;
    my $code_numeric   = $usd->code_numeric;
    my $symbol         = $usd->symbol;
    my $subunit        = $usd->subunit;
    my $subunit_amount = $usd->subunit_amount;
    
    my @countries      = $usd->countries;

METHODS

new()

    my $usd = Locale::Object::Currency->new( country_code => 'us' );

The new method creates an object. It takes a single-item hash as an argument - valid options to pass are ISO 3166 values - 'code' and 'code_numeric'; also 'country_code', which is an alpha2 country code. If you give a country code, a currency object will be created representing the currency of the country you specified.

The objects created are singletons; if you try and create a currency object when one matching your specification already exists, new() will return the original one.

name(), code(), code_numeric(), symbol(), subunit(), subunit_amount()

    my $name = $country->name;
    

These methods retrieve the values of the attributes in the object whose name they share.

countries()

    my @countries = $usd->countries;

Returns an array (in array context, otherwise a reference) of Locale::Object::Country objects with their ISO 3166 alpha2 codes as keys for all countries using this currency in array context, or a reference in scalar context. The objects have their own attribute methods, so you can do things like this for example:

    foreach my $place (@countries)
    {
      print $place->name, "\n";
    }
    

Which will list you all the countries that use in that currency. See the documentation for Locale::Object::Country for a listing of country attributes. Note that you can chain methods as well.

    foreach my $place (@countries)
    {
      print $place->continent->name, "\n";
    }

KNOWN BUGS

The database of currency information is not perfect by a long stretch. If you find mistakes or missing information, please send them to the author.

AUTHOR

Originally by Earle Martin

COPYRIGHT AND LICENSE

Originally by Earle Martin. To the extent possible under law, the author has dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.