Please send questions to
st10@humboldt.edu .
#!/usr/bin/perl -w
#######################################################
# lect06_warn
#
# now addiing some practice using Perl warn function
#
# modified by Sharon Tuttle from "Learning Perl",
# by Schartz and Phoenix
#
# last modified: 9-28-04
#######################################################
# 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)";
print "what does this do? $!\n";
}
$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 lect06_warn