#!/usr/bin/perl #Creates a function to average the test scores sub finalScore{ #Creates a scalar variable of the number of test scores entered. $n = scalar(@_); #creates a variable of the number of test scores entered. $total = 0; #for each test within the array finalScore, the total is added. foreach $test (@_){ $total += $test; } #The total is divided by the number of tests to get the average giving the final score. $finalScore = $total / $n; print "Your final score is : $finalScore\n"; } finalScore(86, 99, 78, 55, 100, 93, 77, 83); #This determines whether or not the student passed or failed the class based on the final score. $passorfail = ($finalScore > 80 )? "You passed the class" : "You failed the class"; #This prints whether the student passes or fails the class print "- $passorfail\n";