use stict; use warnings; my @words = ("a", "abbey", .. "zymophore", "zymophoric"); #in reality, this is a list of all words in the english #language aproximatly 400,000 words long my $sentance = <>; my @sentanceSplit = split(' ', $lcsentance); #all words need to be lower case #for simplicity, say we type "a zymophoric". my @indexes; foreach my $place (@sentanceSplit) { push @indexes, sprintf '%06d', first_index { $_ eq $place } @words; }; #because of our input, @indexes will print 000000 399999 #because 'a' is in the 0th position of @words therfore #000000 #and 'zymophoric' is in the 400 thousandth position #retuning 399999 my @numbers2 = ("250690", "004058", ..); #400,000 numbers but in a random order instead of #(0..399999) #my goal now is to take the values from @indexes and #compare them to @numbers2 and say (values of @indexes are #0 399999) notice we remove the leading zeros. Then look #for what is foreach in the oth position of @numbers2 ie. #"250690" and the 399999th position returning whatever it #finds lets say 000001 #then have my @new = whatever the result is, so ("250690", #"000001");