<DIV>
<DIV>Perhaps providing an example file would help too - assuming Kevin's resolution does not fix your error completely. </DIV>
<DIV>&nbsp;</DIV>
<DIV>Either way, here's a little hint to help keep your code a bit "cleaner". On the line:</DIV>
<DIV>&nbsp;</DIV>
<DIV>( my $student, my $grade ) = split( '\t', $line );</DIV>
<DIV>&nbsp;</DIV>
<DIV>You can change it to:</DIV>
<DIV>&nbsp;</DIV>
<DIV>my ($student, $grade) = split( '\t', $line );</DIV>
<DIV>&nbsp;</DIV>
<DIV>It may not seem like much of a difference in this example, but IMHO when you start having more variables, your lines of code could get long and ugly looking. </DIV>
<DIV>&nbsp;</DIV>
<DIV>...I know, I know...it's petty ;-)</DIV>
<DIV>&nbsp;</DIV>
<DIV>-Dan<BR><BR><B><I>"Shankar, Ganesh" &lt;Ganesh.Shankar@RoswellPark.org&gt;</I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">I'm new to perl and learning by running examples. I'm using a script from Programming Perl, 2nd edition, 2nd chapter. There's a script involving getting the average grades of students (http://www.oreilly.com/catalog/pperl2/excerpt/ch01.html#PERL2-CH-1-SECT-3). <BR>Essentially students are listed in the first column and their scores are listed in the second column. The student can be listed multiple times in the first column. The script should gather all the scores for each student and average them. Then print out the student's name once and their corresponding average.<BR><BR>I have to do something analogous in my microarray data analysis. I copied the script, added strict and warning, assigned scope to the variables and ran into a syntax problem on this line: my $grades{$student} .= $grade . " ";. I'm trying to figure out how the program works but I can't see the syntax error.
 <BR><BR>Thanks for any help.<BR><BR><BR><BR>#!/usr/bin/perl<BR>use strict;<BR>use warnings;<BR><BR>open( GRADES, "grades" ) or die "Can't open grades: $!\n";<BR>while ( my $line = <GRADES>) {<BR>( my $student, my $grade ) = split( '\t', $line );<BR>my $grades{$student} .= $grade . " ";<BR>}<BR><BR>foreach $student ( sort keys my %grades ) {<BR>my $scores = 0;<BR>my $total = 0;<BR>my @grades = split( '\t', $grades{$student} );<BR>foreach $grade (@grades) {<BR>$total += $grade;<BR>$scores++;<BR>}<BR>my $average = $total / $scores;<BR>print "$student: $grades{$student}\t Average: $average\n";<BR>}<BR><BR><BR>_______________________________________________<BR>Buffalo-pm mailing list<BR>Buffalo-pm@mail.pm.org<BR>http://mail.pm.org/mailman/listinfo/buffalo-pm<BR></BLOCKQUOTE></DIV><p>
                <hr size=1>Do you Yahoo!?<br>
Win 1 of 4,000 free domain names from Yahoo! <a
href="http://us.rd.yahoo.com/evt=26640/*http://promotions.yahoo.com/goldrush">Enter now</a>.