foreach my $string ( @data ) { # dedupe data and sanity check. next if !defined ($string); # should never be true. next if $seen{ $string }[ 0 ] == 1; # check %seen hash / array for dupe $seen{ $string }[ 0 ] = 1; # define hash of array and assign check to it. $seen{ $string }[ 1 ] = $key; # add word from line to hash for reference. }