use strict;
print "Enter last 4 digits of phone number:";
chomp(my $number=<>);
die "Invalid number: '$number'\n" unless $number=~/^\d{4}$/;
my @d=split(undef,$number);
my %map={
2=>"[abc]",
3=>"[def]",
4=>"[ghi]",
5=>"[jkl]",
6=>"[mno]",
7=>"[pqrs]",
8=>"[tuv]",
9=>"[wxyz]",
};
my $r=$map{$d[0]}.$map{$d[1]}.$map{$d[2]}.$map{$d[3]};
open FILE,"</usr/share/dict/words";
my $x=0;
while(<FILE>){
chomp;
if($_=~/^$r$/){
print "$_\n";
}
$x++;
}
This program is suppose to construct a regular expression mapping the letters to character classes then search the file for matching words to find what the last four digits of a phone number may spell.
My problem is that it is not giving me any output.
Any help would be greatly appreciated.