my $test = join(' and ', map { join(',', @$_) } grep(@$_, \@a, \@b, \@c, \@d, \@e, \@f, \@g));