my %lookup = (); # initialize the hash while (defined ($line = )) { my @line = split /\s+/, $line; if (defined ($lookup{$line[1]})) { # array indexes start at 0 # if the hash key already has been defined (see below)... exit(0); # error out; } else { $lookup{$line[1]} = 1; # define the lookup value; } }