Blob


1 #!/usr/bin/perl
3 #Write a program that will ask the user for a given name and report the
4 #corresponding family name. Use the names of people you know, or (if you spend
5 #so much time on the computer that you don't know any actual people) use the
6 #following table:
7 #
8 #Input Output
9 #==========================
10 #fred flintstone
11 #barney rubble
12 #wilma flintstone
14 use v5.10;
15 use warnings;
16 use strict;
17 use utf8;
19 my %names = (
20 fred => "flintstone",
21 barney => "rubble",
22 wilma => "flintstone",
23 );
24 my $name;
25 print "Type a name: ";
26 while (defined(chomp($name = <>))) {
27 print $name." ". $names{$name}."\n";
28 print "Type a name: ";
29 $name = undef;
30 }