The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Data::Maker::Field::Currency - A Data::Maker field class used for generating random currency values.


  use Data::Maker;
  use Data::Maker::Field::Currency;
  my $maker = Data::Maker->new(
    record_count => 10,
    fields => [
        name => 'price',
        class => 'Data::Maker::Field::Currency',
        args => {
          min => 200,
          max => 3000,
          iso_code => 'USD'


Data::Maker::Field::Currency is a subclass of Data::Maker::Field::Number, with the precision attribute set to 2 and the separate_thousands attribute defined as true.

This class also supports the following Moose attributes:

  • iso_code

    A valid currency code, as defined by ISO 4217. Defaults to USD.

  • code

    An alias for iso_code

  • as_float (Bool)

    If set to a true value, the generated value will be returned as a float, without any currency formatting.

  • with_code (Bool)

    If set to a true value, the generated value will be returned, prefixed by the country code


John Ingram (


Copyright 2010 by John Ingram. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.