in reply to Getting values for next array iteration when matching current

With a sufficiently recent version of Perl, you can do:
use Modern::Perl; my @ref = qw/aap noot mies wim zus jet teun vuur gijs lam kees bok/; while (my $in = <DATA>){ chomp $in; while (my ($index, $value) = each @ref) { if ($value=~ m/$in/){ say "$in : $value : $ref[$index + 2]"; } } } __DATA__ a e i o u aa ee ie oo uu
output:
a : aap : mies a : lam : bok e : mies : zus e : jet : vuur e : teun : gijs e : kees : i : mies : zus i : wim : jet i : gijs : kees o : noot : wim o : bok : u : zus : teun u : teun : gijs u : vuur : lam aa : aap : mies ee : kees : ie : mies : zus oo : noot : wim uu : vuur : lam
Of course you get a number of Use of uninitialized value in concatenation (.) or string at ... warnings because you access unitialized elements of the array.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James