#! /usr/bin/perl use strict; use warnings; my @pages = ( { 'mid' => '164', 'texts' => [ undef, 'FGFDBB' ], 'class' => 'DT' }, { 'mid' => '159', 'texts' => [ undef, 'arfara' ], 'class' => 'DT' }, { 'mid' => '154', 'texts' => [], 'class' => 'DT' }, { 'mid' => '153', 'texts' => [ undef, '', 'GAGRE', '', '' ], 'class' => 'DT' }, { 'mid' => undef, 'texts' => [], 'class' => 'DT' }, ); my @checked = map { $_->{class} ne 'DT' ? 1 : ( defined($_->{mid}) && grep ( /\w+/ , @{$_->{texts}} ) ? 1 : 0 ) } @pages;