#!/usr/bin/env perl
use strict;
use warnings;

print "Please enter three names, separated by commas:\n";
chomp(my $name_string = <STDIN>);
my @names = split ',', $name_string;

my %grade_of;

#In reality, we'd use a loop at this point, but we haven't covered
#loops yet, so we'll deal with a little code-duplication...
print "Please enter the grade for $names[0]:\n";
chomp($grade_of{$names[0]} = <STDIN>);
print "Please enter the grade for $names[1]:\n";
chomp($grade_of{$names[1]} = <STDIN>);
print "Please enter the grade for $names[2]:\n";
chomp($grade_of{$names[2]} = <STDIN>);

#there are two ways we've covered to display the next prompt,
#either using join to create a new string, or localizing a 
#change to the $, variable:

my $all_names = join ', ', @names;
print "Please enter one of the names ($all_names)\n";

#OR...
#print "Please enter one of the names (";
#{
#   local $, = ', ';
#   print @names;
#}
#print ")\n";

chomp(my $chosen = <STDIN>);
print "The grade for $chosen is $grade_of{$chosen}\n";


