use FreezeThaw qw(cmpStr); sub f { my ($h) = @_; return grep cmpStr(@{$h->{$_}}{qw/C O/}), keys %$h; }