#!/usr/bin/perl use LWP::Simple; #open (IN, "test2.csv"); open (FILE, ">myOutput.tdf"); $file = get "http://www.cs.umd.edu/~golbeck/perl/test1.csv"; @lines = split(/\n/, $file); $total = 0; $count = 0; #while () { foreach $line (@lines) { #$line = $_; ($year, $price, $adj_price) = split(/,/, $line); #print "$year\n"; $count++; $total = $total + $price; $ratio = $adj_price / $price; print FILE "$year\t$ratio\n"; } close FILE; $avg = $total / $count; print "$avg\n";