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

NAME

App::CalcAccumulatedInflation - Calculate accumulated inflation over the years

VERSION

This document describes version 0.050 of App::CalcAccumulatedInflation (from Perl distribution App-CalcAccumulatedInflation), released on 2021-04-01.

SYNOPSIS

See the included script calc-accumulated-inflation.

FUNCTIONS

calc_accumulated_inflation

Usage:

 calc_accumulated_inflation(%args) -> any

Calculate accumulated inflation over the years.

Examples:

  • See accumulated 6%/year inflation for 10 years:

     calc_accumulated_inflation(yearly_rate => 6);

    Result:

     [
       { index => 1, year => 0 },
       { index => "1.0600", year => 1 },
       { index => 1.1236, year => 2 },
       { index => "1.1910", year => 3 },
       { index => 1.2625, year => 4 },
       { index => 1.3382, year => 5 },
       { index => 1.4185, year => 6 },
       { index => 1.5036, year => 7 },
       { index => 1.5938, year => 8 },
       { index => 1.6895, year => 9 },
       { index => 1.7908, year => 10 },
     ]
  • Indonesia's inflation rate for 2003-2014:

     calc_accumulated_inflation(rates => [5.16, 6.4, 17.11, 6.6, 6.59, 11.06, 2.78, 6.96, 3.79, 4.3, 8.38, 8.36]);

    Result:

     [
       { index => 1, year => 0 },
       { index => 1.0516, rate => "5.16%", year => 1 },
       { index => 1.1189, rate => "6.40%", year => 2 },
       { index => 1.3103, rate => "17.11%", year => 3 },
       { index => 1.3968, rate => "6.60%", year => 4 },
       { index => 1.4889, rate => "6.59%", year => 5 },
       { index => 1.6536, rate => "11.06%", year => 6 },
       { index => 1.6995, rate => "2.78%", year => 7 },
       { index => 1.8178, rate => "6.96%", year => 8 },
       { index => 1.8867, rate => "3.79%", year => 9 },
       { index => 1.9678, rate => "4.30%", year => 10 },
       { index => 2.1327, rate => "8.38%", year => 11 },
       { index => "2.3110", rate => "8.36%", year => 12 },
     ]

This routine generates a table of accumulated inflation over a period of several years. You can either specify a fixed rate for every years (yearly_rate), or specify each year's rates (rates).

This function is not exported.

Arguments ('*' denotes required arguments):

  • base_index => float (default: 1)

  • base_year => float (default: 0)

  • rates => array[float]

    Different rates for each year, in percent.

  • yearly_rate => float

    A single rate for every year, in percent.

  • years => int (default: 10)

Return value: (any)

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/App-CalcAccumulatedInflation.

SOURCE

Source repository is at https://github.com/perlancar/perl-App-CalcAccumulatedInflation.

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/perlancar/perl-App-CalcAccumulatedInflation/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2021, 2019, 2017, 2015 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.