O enlightened ones, here is my question:
I am going through the llama book (which, by the way, is the most useful
tool
I have bought so far for perl reference) in order to learn perl. On page 10
is a simple script which I copied and have attempted to execute for the last
1/2 hour. Please tell me what is wrong!
I'm using ActiveStatePerl5.6.1 and Apache web server on M$ win98se.
##############perl script file name: gradation.pl ##################
#!c:/perl/bin/perl -w
open(GRADES, "c:\perl\eg\grades.txt") or die "Can't open grades: $!\n";
while ($line = <GRADES>) {
($student, $grade) = split(" ", $line);
$grades{$student} .= $grade . " ";
}
foreach $student (sort keys %grades) {
$scores = 0;
$total = 0;
@grades = split(" ", $grades{$student});
foreach $grades (@grades) {
$total += $grade;
$scores++;
}
$average = $total / $scores;
print "$student: $grades{$student}\tAverage: $average\n";
}
##### my text file is as follows, and is called "grades.txt" in same path as
gradation.pl
Noel 25
Ben 76
Clementine 49
Norm 66
Chris 92
Doug 42
Carol 25
Ben 12
Clementine 0
Norm 66
...
# Resulting error messages
Unrecognized escape \p passed through at c:\perl\eg\gradation.pl Line 3
Unrecognized escape \g passed through at c:\perl\eg\gradation.pl Line 3
Can't open grades: No such file or directory
######### That's it #########
Thanks for any help.
Standing by with a water hose,
Nathan