# hash.lib # in the library sub gethash { my %hash; open(FILE, "data.txt") || die "Can't open data - $!\n"; # dick:98 # robert:76 # mary:68 chomp(my @lines = ); close(FILE); foreach (@lines) { my ($name,$score) = split /:/, $_; $hash{name} = $name; $hash{score} = $score; } return \%hash; }