in reply to Keeping separate array data related

foreach (keys %texts)
You kinda lost me here. You speak about arrays but keys and %texts are clearly (update: related to) hashes to me. What exactly do you want?

As for your question, use a hash indeed. I suppose that when a text entry occurs twice, the same image occurs twice as well?

$texts_and_images{"$text"} = $image; # set text and image @all_texts = keys %texts_and_images; # have a list of all texts @all_images = values %texts_and_images; # have a list of all images $image = $texts_and_images{"$text"); # have the associated image of + a text
HTH