my @array1 = qw(a b c d e); my @array2 = qw(a c d e b); # assign numbers and create lookup table my $i; my %pos1 = map { $_ => ++$i } @array1; # lookup items of array2 my @pos2 = map $pos1{$_}, @array2; print "@pos2\n"; # 1 3 4 5 2