title: Perl - Using regex to match input in hash key or value
body: <p>First, this is a homework assignment. I am having a tough time with regex, and I'm stuck.</p>
  
  <p>This is the code I have so far, where I have the user designate a filename, and if it exists, populates a hash of the names as keys, and the phone numbers as the values.</p>
  
  <pre><code>#!/usr/bin/perl
  
  use strict;
  
  print "\nEnter Filename: ";
  my $file = &lt;STDIN&gt;;
  chomp $file;
  
  if(!open(my $fileName, "&lt;", "$file"))
  {
      print "Sorry, that file doesn't exist!", "\n";
  }
  else
  {
      my %phoneNums;
      while (my $line=&lt;$fileName&gt;) 
      {
          chomp($line);
          (my $name,my $number) = split /:/, $line;
          $phoneNums{$name} = $number;
      }
  
      print "Read in the file!", "\n\n";
  
      print "Enter search: ";
      my $input = &lt;STDIN&gt;;
      chomp $input;
  
      #HERE IS WHERE I'M LOST
  }
  
  print "\n";
  </code></pre>
  
  <p>This is the part I am stuck on:</p>
  
  <p>Allow the user to enter a search string.
  Look for matches using the same style as the phone. Any individual
  character in the search string can match any other character from the
  key, meaning a ‘2’ in the search string can match a ‘2’, ‘A’, ‘B’, or ‘C’ in the contact list. Matches can occur in the contact name or the phone number. For a match to occur, each character in the search string must appear, in order, in the contact info, but not necessarily next to each
  other. For example, a search string of “86” (essentially the same as a search string of “TM” or “NU”) would match “TOM” but not “MOTHER”.
  Characters on each phone keys:
  0,
  1,
  2ABC,
  3DEF,
  4GHI,
  5JKL,
  6MNO,
  7PQRS,
  8TUV,
  9WXYZ</p>
  
  <p>I just am stuck on how exactly to make all those character classes, and any help at all is much appreciated.</p>