foreach $test (keys %Tests) { print "Test and students are\n $test:\n"; $" = "\n"; # Only do the sort and join with newlines # if there's more than one student. if (@{ $Tests{$test} } > 1){ @tempvar1 = sort( @{ $Tests{$test} }); $i = 0; #Making sure everything is sorted, and will #actually print. Had problems with lines being #dropped. $tempvar = @{ $Tests{$test} }; print $tempvar, "\n"; while ($i < @{ $Tests{$test} }){ print $Tests{$test}[$i]; print "\n"; $i++; } $tempvar2 = @tempvar1; print $tempvar2, "\n"; print "@tempvar1"; # print $tempvar1 . "hello\n"; # print join("|", sort @{ $Tests{$test} }); } else {print "@{ $Tests{$test} }\n";} print ",,,,,,,,,\n,,,,,,,,,\n"; }