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.
In reply to Re: Simple Hash Usage
by almut
in thread Simple Hash Usage
by kapoor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |