# you originally have two parallel arrays of related data my @a = (6, 7, 8); my @b = (3, 2, 1); # So you need to use artificial means to put the data together, such as an index variable for my $index (0 .. $#a) { my ($a,$b) = ($a[$index], $b[$index]); print $a, "\n" if $b>1; } # If instead you keep the related data items together in a two-dimensional array: my @c = ( [6,3], [7,2], [8,1] ); # Then printing the related data is easy, and you needn't track the array index for my $item (@c) { my ($a,$b) = @$item; print $a, "\n" if $b>1; }