#!/bin/perl -w # if inside a loop - loopylast.pl # Sums and averages a mximum of four numbers for ($k=1; $k<5; $k++) { print "Enter a numerical value or DONE please:- "; $num = ; chop $num; if ($num eq "DONE") { print "End of input encountered\n"; last; } $sum += $num; } print "Total = ",$sum, "\n"; print "Average ", $sum / ($k - 1), "\n";;