in reply to Simple Hash Usage

print "\nAsking user which he/she taking: "; my $choice = <STDIN>; chomp($choice); if (exists $elective{$choice} ) { print "You will be taking the $elective{$choice} prog course\n"; } else { print "No course taken\n"; }

When you evaluate an array in scalar context (@k == <stdin>), you'll get the number of its elements, i.e. 4 in this case.