use List::Util qw/max min/; my @result = map max($s1,$a[$_])..min($s2,$b[$_]), 0..$#a;