#! /usr/bin/env perl use strict; use warnings; my @a = ( 6,7,8 ); my @b = ( 3,2,1 ); my @c = map { $b[$_] > 1 ? $a[$_] : () } 0 .. $#a; print "@c\n";