while( my $r = $iter->next ) { my ( $z, $y, $x, $w ) = @{ $r }; next unless $w-2*$x+$y or $x-2*$y+$z; print "$w, $x, $y, $z\n"; }