#!/usr/bin/perl use strict; use warnings; use List::Util qw/min max/; use Data::Dumper; my @a1 = qw(a d g v 6 z h u t f e 0 n); my @a2 = qw(h f t u); my %pos = map { $a1[$_], $_ } 0..$#a1; #print Dumper \%pos; my @t = map { $pos{$_} } @a2; print min(@t) . ", " . max(@t) . "\n";