Blob


1 #!/usr/bin/perl
3 #Write a program that reads a list of numbers (on separate lines)
4 #until end-of-input and then prints for each number the
5 #corresponding person's name from the list shown below. (Hardcode
6 #this list of names into your program. That is, it should appear in
7 #your program's source code.) For example, if the input numbers
8 #were 1, 2, 4, and 2, the output names would be fred, betty, dino,
9 #and betty:
10 #
11 #fred betty barney dino wilma pebbles bamm-bamm
13 use warnings;
14 use strict;
15 use utf8;
17 my @names = qw(fred betty barney dino wilma pebbles bamm-bamm);
18 print "Type numbers from 1-7, one on each line. Once finished, type ^d:\n";
19 chomp(my @numbers = <STDIN>);
20 foreach (@numbers) {
21 print "$names[$_-1]\n"
22 }