Created
November 28, 2011 08:18
-
-
Save numberwhun/1399582 to your computer and use it in GitHub Desktop.
Print names corresponding to numbers in a list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################# | |
# Script: nuum2name.pl | |
# Author: Jefferson Kirkland | |
# Company: JK Web Development | |
# Copyright: 2008 | |
# | |
# Description: This script takes a list of numbers, supplied by the user, and | |
# converts the numbers into names. The script then prints them out to show the | |
# user what names the numbers corresponded to. | |
# | |
################################################################################# | |
use strict; | |
use warnings; | |
my %names = (1 => "Joe", | |
2 => "Bob", | |
3 => "George", | |
4 => "Connor", | |
); | |
print("Please enter your list of numbers from 1 to 4, one number per line. Press Ctrl-Z when finished.\n"); | |
my @num = <STDIN>; | |
print("There are $#num elements in the array"); | |
print("The names you requested are:\n"); | |
foreach my $line (@num) | |
{ | |
chomp($line); | |
#print("$line\n"); | |
print("$names{$line}\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment