tim = 40 , 70, 50, 80 john = 98, 97 , 100, 89 eden = 87, 56, 89, 97 pepe = 93 ,91, 94, 90 leah = 100, 99, 99, 100 tony = 89, 94, 100, 89 matt = 68, 70, 75, 73 #### use strict; use warnings; use Data::Dump qw(dump); use autodie; my %ave; open my $in,'<', "testscores.txt"; while (<$in>){ my ($name, $score) =split /[\s=s,]+/; for (0..3){ $ave{$name}[$_]=$score; } } #dump \%ave; get_ave(\%ave); #get it by hash_ref my %hash_ref; #why do I have to declare ? sub get_ave{ my $hash_ref =@_; #declared here too? my %hash=%$hash_ref; dump \%hash; #dump \%hash_ref; }