Data::Currency

Data::Currency is a container class for currency conversion/formatting.
Download

Data::Currency Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Christopher H. Laco
  • Publisher web site:
  • http://search.cpan.org/~claco/Handel-1.00009/lib/Handel/Manual/QuickStart.pod

Data::Currency Tags


Data::Currency Description

Data::Currency is a container class for currency conversion/formatting. Data::Currency is a container class for currency conversion/formatting.SYNOPSIS use Data::Currency; my $price = Data::Currency->new(1.2. 'USD'); print $price; # 1.20 USD print $price->code; # USD print $price->format; # FMT_SYMBOL print $price->as_string; # 1.20 USD print $price->as_string('FMT_SYMBOL'); # $1.20 print 'Your price in Canadian Dollars is: '; print $price->convert('CAD')->value;The Data::Currency module provides basic currency formatting and conversion: my $price = 1.23; my $currency = Data::Currency->new($price); print $currency->convert('CAD')->as_string;Each Data::Currency object will stringify to the original value except in string context, where it stringifies to the format specified in format.CONSTRUCTORnewArguments: $price || %optionsTo create a new Data::Currency object, simply call new and pass in the price to be formatted: my $currency = Data::Currency->new(10.23); my $currency = Data::Currency->new({ value => 1.23, code => 'CAD', format => 'FMT_SYMBOL', converter_class => 'MyConverterClass' });You can also pass in the default currency code and/or currency format to be used for each instance. If no code or format are supplied, future calls to as_string and convert will use the default format and code values.You can set the defaults by calling the code/format values as class methods: Data::Currency->code('USD'); Data::Currency->format('FMT_COMMON'); my $currency = Data::Currency->new(1.23); print $currency->as_string; # $1.23 my $currency = Data::Currency->new(1.23, 'CAD', 'FMT_STANDARD'); print $currency->as_string; # 1.23 CADThe following defaults are set when Data::Currency is loaded: value: 0 code: USD format: FMT_COMMON Requirements: · Perl


Data::Currency Related Software