#!/usr/bin/perl -w
use strict;
use constant NL => qq[\n]; # a less ugly new line

# set up your table
my($table) =
   {
   123 =>      # A table column named "123"
      [  763,  # The list of values within table column "123"...
         445,
         841,
         630,
         640,
      ],
   456 =>      # A table column named "456"
      [  554,  # The list of values within table column "456"...
         436,
         389,
         522,
         203,
      ],
   789 =>      # A table column named "789"
      [  322,  # The list of values within table column "789"...
         106,
         300,
         251,
         106,
      ]
   };

# user input:
my($input_1) = 456; # (hopefully) corresponds to a column within the table
my($input_2) = 389; # (hopefully) corresponds to a value within the table column

# The user's first input argument should match a column name in the table.
# Print out error message if the table contains no column matching the user's
# first input argument.
print qq[No such column as "$input_1" exists in the table.], NL x 2 and exit
   unless exists $table->{ $input_1 };

# If the table contains a column name that matches the user's first input
# argument, the user's second input argument needs to match up with a value
# in that table column.  Check that column for an entry that matches the user's
# second input argument.
if (&find_in_column( $input_2, @{ $table->{ $input_1 } } )) {

   # print a success message if the user's second input argument matches
   # a value in that table column
   print qq[Match found!  Value "$input_2" exists in table column "$input_1"];
}
else {

   # print a failure message if the user's second input argument doesn't
   # match up with any value in that table column
   print qq[No such value as "$input_2" exists in table column "$input_1"];
}

print NL x 2 and exit;

# subroutine used to look up a value within a list of items
# usage: &find_in_column([item to search for], [list to search in])
sub find_in_column {

   my($lookup,@list) = @_;

   my(%lookup_hash) = (); @lookup_hash{ @list } = ();

   return exists $lookup_hash{ $lookup };
}