#! perl ############ This script takes the number a user entered and returns the corrseponding name. ##### Create the list of names @names = qw / fred betty barnet dino wilma pebbles bam-bam /; ### # test to make sure @names is define correctly # # print @names; ### ###### Greet user and get the number from the user. print "\nWelcome to the name program.\nPlease enter a number or numbers and hit crtl + D when done: "; @userNumber = ; ### test to dump array # # print @userNumber; ### ### test to see what $counter would be when used in foreach loop #$counter = @userNumber; #print $counter; ### ###### Return a name based on the number provided. foreach $counter (@userNumber) { print "\nthe name is: $names[$counter - 1] "; }