#!/usr/local/bin/perl -w if (@ARGV<1){ print < This programs accepts as input file format: lowrate,highrate,step cashflowA1 cashflowA2 ... cashflowAN cashflowB1 cashflowB2 ... cashflowBM EOT ; exit -1; } open IN, "<".$ARGV[0] or die "Cannot open $ARGV[0]: $!"; chomp ($in = ); ($lo,$hi,$step) = split /,/,$in; while (){ $counter++; @cashflow = split /\s+/; for ($i = $lo; $i<=$hi; $i+=$step){ print "Project $counter, rate $i: NPV = "; $npv=0; $index=0; for $cf (@cashflow){ $npv += $cf/((1+$i)**$index); $index++; } print "$npv\n"; } } __END__