http://qs321.pair.com?node_id=1231199

bigup401 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: calc percentage
by hdb (Monsignor) on Mar 13, 2019 at 09:32 UTC

    5% is shorthand for 0.05. Therefore, 5% of 50000 is 0.05 * 50000 = 2500.

    More generally: x% is shorthand for x/100. Therefore, x% of y is x / 100 * y.

      thanks, this has given me much idea

Re: calc percentage
by thanos1983 (Parson) on Mar 13, 2019 at 09:19 UTC

    Hello bigup401,

    Do you mean something like that?

    percentage = partialAmount / totalAmount totalAmount = partialAmount / percentage partialAmount = percentage * totalAmount

    If so this is a not a Perl related question. Unless if you mean if there is a module that can do this calculation for you?

    Update: Also look at the Math::PercentChange is this what you are looking for? From to percentage difference?

    BR / Thanos

    Seeking for Perl wisdom...on the process of learning...not there...yet!

      Any. which can do for me that calculation . if there is a module or a example without a module i appreciate

        Hello bigup401,

        I do not know if you saw my updated answer but here is an example that you can use a module and it will do the calculation for you (see below):

        #!/usr/bin/perl use strict; use warnings; use feature 'say'; use Math::PercentChange qw(f_percent_change); my $from = 10; my $to = 15; say f_percent_change($from, $to, "%.03f"); __END__ $ perl test.pl 50.000%

        Hope this helps, BR.

        Seeking for Perl wisdom...on the process of learning...not there...yet!