#!/usr/local/bin/perl $args = $ENV{'QUERY_STRING'}; print <How Much to Retire? HTMLHeader if (length($args) < 3) { print <How Much to Retire?

Here is a new simple retirement calculator. It tells how much you will need to provide a certain income for a set number of years.


  • Annual Income Required (today's dollars)
  • Number of years until retirement
  • Number of years required after retirement
  • Annual Inflation
  • Annual Yield on Balance (%) (fixed loan)

  • by Hugh Chou FullForm } else { print "

    Retirement Estimations

    \n"; print "

    Inputs

    \n"; # Let's do the calculations! $args =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig; $args =~ s/[ ,]//g; @va = split("&",$args); for ($i=0; $i<7; $i++) { @va[$i] = substr(@va[$i],5); } ($inc,$unt,$yrs,$inf,$yld,$ott) = @va; $irat = 1 + $inf/100; # inflation ratio $icf = sprintf("%10.2f",$inc * ( $irat ** $unt )); # future income if ($ott =~ /Plain/) { print "
  • Required Income: \$ $inc (Current Dollars)\n"; print "
  • Required Income: \$ $icf (Future Dollars)\n"; print "
  • Number of Years until retiring : $unt \n"; print "
  • Number of Years after retiring : $yrs \n"; print "
  • Annual Inflation : $inf %\n"; print "
  • Annual Yield on Balance: $yld % \n"; } else { print "\n"; print "
    Required Income (Current Dollars) \$ $inc \n"; print "
    Required Income (Future Dollars) \$ $icf \n"; print "
    Number of Years Until Retiring $unt \n"; print "
    Number of Years After Retiring $yrs \n"; print "
    Annual Inflation (on Required Income) $inf %\n"; print "
    Annual Yield on Balance$yld % \n"; print "
    \n"; } print "
    \n"; $iy = $yld/100; $oinc = $icf; if ($inf > 0) { $icf = $icf * ($irat ** $yrs); } for ($i=0; $i<$yrs; $i++) { if ($inf > 0) { $icf = $icf/ (1 + $inf/100); } $bal = $bal / (1 + $iy) + $icf; } printf("

    You will need \$ %10.2f

    \n",$bal); $icf = $oinc; if ($ott =~ /HTML/) { print "\n"; print "
    YearBeg BalWithdrawInterestEnd Bal\n"; } for ($i=1; $i<=$yrs; $i++) { $bbal = $bal; $bal = $bal - $icf; $earn = $bal * $yld/100; $bal = $bal + $earn; if ($ott =~ /Plain/) { printf("
  • Year %2d : Beg Balance %10.2f Withdraw %9.2f Interest %9.2f End Balance %9.2f\n", $i, $bbal, $icf, $earn, $bal); } else { printf("
  • %2d %10.2f %9.2f %9.2f %9.2f\n", $i, $bbal, $icf, $earn, $bal); } if ($inf > 0) { $icf = $icf * (1 + $inf/100); } } if ($ott =~ /HTML/) { print "
    \n"; } print < For more looking at what current monthly deposits and balances you need, see the annuity calculator. Trailer }