Skip to content

Instantly share code, notes, and snippets.

@numberwhun
Created November 28, 2011 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save numberwhun/1399582 to your computer and use it in GitHub Desktop.
Save numberwhun/1399582 to your computer and use it in GitHub Desktop.
Print names corresponding to numbers in a list
#################################################################################
# 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