Just for the sake of one more way to do it:

###########################

use strict;
use warnings;

my %numbers;
my $letter = 'a';
my $userinput = 23;

foreach(1..26){
    $numbers{$_} = $letter;
    $letter++;
}

if(defined($numbers{$userinput})){
   print "It's good!\n";
}else{
   print "Invalid number.\n";
}

############################



-----Original Message-----
From: The Ghost [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 26, 2006 10:28 PM
To: Perl Beginners
Subject: num to alpha

What's the easiest way for me to turn a number into a letter?

2 -> b
5 -> e
26 -> z
27 -> error

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to