Im trying to get my program to look like the following
The nominees for Outstanding Comedy Series are:
[1] Write In
[2] The Big Bang Theory, CBS
[3] Curb Your Enthusiasm, HBO
[4] Girls, HBO
[5] 30 Rock, NBC
[6] Veep, HBO
[7] Modern Family, ABC
Please enter your choice for Outstanding Comedy Series now: 0
I'm sorry, but 0 is not a valid option.
Please enter your choice for Outstanding Comedy Series now: 8
I'm sorry, but 8 is not a valid option.
Please enter your choice for Outstanding Comedy Series now: -1
I'm sorry, but -1 is not a valid option.
Please enter your choice for Outstanding Comedy Series now: 8
I'm sorry, but 8 is not a valid option.
Please enter your choice for Outstanding Comedy Series now: 2
Thank you for selecting The Big Bang Theory, CBS as Outstanding Comedy Series.
I can get the disply to work, but i can not figure outhow to convert a number from user input to apply to an item in my array. And how to validate that the number entered matches the number of items in the array.
Here is what I have so far
#!/usr/bin/perl
use warnings;
use strict; # required for our programs!
use diagnostics;
# Greeting
print "Welcome to the 64th Annual Primetime Emmy Awards!\n ";
print "\n";
print "=" x78;
print "\n";
# Start of nominee ballot section for Outstanding Comedy
print "The nominees for Outstanding Comedy Series are: \n\n";
print "\n";
# Initiating array of comedy nominees
my @comedy = ('Write In','The Big Bang Theory, CBS','Curb Your Enthusiasm, HBO',
'Girls, HBO','30 Rock, NBC','Veep, HBO','Modern Family, ABC');
#Foreach to add numbers infront of choices
my $c =1;
for my $cshow (@comedy)
{
$cshow = " [$c] $cshow";
$c += 1;
}
# $cshow is local variable of @comedy
for my $cshow (@comedy)
{
print $cshow, "\n";
}
# Request for users vote
print "\n";
print "Please enter your choice for Outstanding Comedy Series now: \n";
chomp (my $cpick = <>);
if ($cpick ~~ @comedy)
{
print qq#Thank you for selecting, $cpick, as Outstanding Comedy Series!\n#;
}
print "=" x78;
print "\n";