use strict; # strict is good ++ # Where's warnings? -- sub sum {my $x; $x += $_ for @_; $x } # poorly formatted -- sub avg {sum(@_)/@_} # poorly formatted -- # probably should use scalar @_ instead of just @_ here undef $/; # no need to slurp to do an average for a line -- open(my $F, 'skaters.txt'); # lexical filehandle ++ # please use three-argument open -- # no error check on a system call -- my @x = map{[split/,/]}grep{/\S/}split/\n+/,<$F>; # very poorly formatted -- # uses split to achieve what while ( <$F> ) would have done without the above slurp-- # makes me think well of those who call Perl line noise # combines two loops and two searches on one line += 0 # (good display of power, but could have built up # the data structure over time more clearly) for(@x){ @$_ = ($_->[0],avg(@{[sort{$a<=>$b}@{$_}[1..$#$_]]}[1..$#$_-2])) # nearly incomprehensible -- # partly due to unnecessary terseness and formatting -- # partly due to painful twists of syntax -- # (The hash solution on perlbuzz was simpler and clearer.) } @x = sort{$b->[1] <=> $a->[1]}@x; # poor formatting again -- printf "%-5s %-20s %-20s\n",$_+1,@{$x[$_]} for(0..2); # poor formatting again --