#!/usr/bin/perl

my %namepoints = ();
my $input = "";
my $tempname = "";
my $temppoints = "";

open(NAMES, '/home/estiann/names.txt');

$input = <NAMES>; 
         until($input eq "") {
                if($input =~ /(\w+) (\d+).../) {
			$tempname = $1; $temppoints = $2; }
		 $namepoints{$tempname} = $temppoints;
		 $input = <NAMES>; }

sub chatter {
 if(/chats to everybody[:,] 'chatmordpoints (\w+)'/) {
   if (exists $namepoints{$1}) { print("Ut oh, that name does not exist\n"); }
   else { print("Ok...$1 has $namepoints{$1} points\n"); }
}
}
#output_add(\&chatter);
#1;


foreach $test (sort keys %namepoints) {
 print("$test has $namepoints{$test} points\n");
}
