#!/usr/bin/perl -w ####################################################### # class8_04_warn # # now addiing some practice using Perl warn function # # modified by Sharon Tuttle from "Learning Perl", # by Schartz and Phoenix # # last modified: 5-5-03 ####################################################### # let's say the USUAL way to call this is with 2 or more command # line arguments --- it will work with none or one, but you want # to warn the user that this is non-standard, without # actually killing the program if (@ARGV < 2) { warn "usually called w/ 2 or more args (note no script name, file num)\n"; warn "(this WILL have script name, file num --- no newline at end)"; } $sum = 0; $num_vals = 0; foreach $val (@ARGV) { $sum += $val; $num_vals++; } if ($num_vals == 0) { print "0\n"; } else { printf "%.3f\n", $sum/$num_vals; } # end of class8_04_warn