my %text_image; @text_image{@texts} = @images; for my $text ( keys %text_image ) { my $image = $text_image{$text}; # do stuff with $text and $image... }