To become familiar with the Perl scripting language by modifying parameters for a simple Perl script which calculates interest.
#!/usr/bin/perl -w $principal = 10000; # $principal is our starting amount $year = 2025; # beginning year when interest will begin compounding $duration = 25; # How many years are we saving up? $apr = 9; # This is our annual percentage rate. $compounding = 4; # How often per year the interest is compounded (4 = quarterly) $new_balance = $principal * (1 + $apr / 100 / $compounding) ** ($compounding * $duration); print "Principal: $principal\n"; print "Number of years: $duration\n"; print "Interest rate: $apr%\n"; printf "New principal after $duration years: %10.2f\n",$new_balance; print "\n"; print "YEAR PRINCIPAL INTEREST\n"; print "-----------------------------------\n"; printf "%4d %10.2f 0\n", $year, $principal; for my $i (1 .. $duration) { $year++; $new_balance = $principal * (1 + $apr / 100 / $compounding) ** ($compounding); printf "%4d %10.2f %10.2f\n", $year, $new_balance, $new_balance - $principal; $principal = $new_balance; }