#! perl -w use warnings; use strict; my $foo = { aa => { O => 'zz', C => 'yy' }, # bb => { O => 'xx', C => 'xx' }, cc => { O => undef, C => 'ww' }, # dd => { O => 'vv', C => undef }, # ee => { O => undef, C => undef }, ff => { C => undef }, gg => { O => 0, C => 0 }, hh => { O => undef, C => 0 }, # }; #2345678901234567890123456789012345678901234567890123456789012345678901234567890123 sub f{no warnings;$a=pop;grep{!exists$a->{$_}{O}or$a->{$_}{O}ne$a->{$_}{C}}keys%$a} # 83! print "@{[f($foo)]}\n"; __DATA__ C:\test>201598 dd ff aa hh cc C:\test>