in reply to (Golf) Warningless Comparison
To get the keys:
Shorter:use FreezeThaw qw(cmpStr); sub f { my ($h) = @_; return grep cmpStr(@{$h->{$_}}{qw/C O/}), keys %$h; }
If you want the actual *entries* (which is what you asked for), it can be shorter:use FreezeThaw 'cmpStr';sub f{my($h)=@_;grep{!exists$$h{$_}{O}||cmpStr +@{$$h{$_}}{C=>'O'}}keys%$h}
This, by the way, is where 1 and '1' differ, see also DBI: when 1 != '1'.# 1 2 3 4 5 #23456789012345678901234 56789012345678901234567890 use FreezeThaw 'cmpStr';sub f{grep{!exists$$_{O}||cmpStr # 6 7 #2345678901234567890123456 @$_{C=>'O'}}values%{$_[0]}}
- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.
|
|---|