So my best was 126 Now to see the others....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 }, # ii => { O => undef }, # }; #Only does defined not exists #98 sub d {$a=pop;grep{$b=$$a{$_};defined$$b{O}!=defined$$b{C}||defined$$b +{O}&&$$b{O}ne$$b{C}}keys%$a} #Does defined and exists #126 sub f {$a=pop;grep{$b=$$a{$_};exists$$b{O}!=exists$$b{C}||defined$$b{O +}!=defined$$b{C}||defined$$b{O}&&$$b{O}ne$$b{C}}keys%$a} # [tadman]s original solution compressed #162 sub t {my($h)=@_;grep{!exists($h->{$_}->{O})||(defined($h->{$_}->{O})? +(defined($h->{$_}->{C})?($h->{$_}->{O} ne $h->{$_}->{C}):1):defined($ +h->{$_}->{C}))}keys%$h} print "d():\n",join("\n",sort {$a cmp $b}d($foo)),"\n\n"; print "f():\n",join("\n",sort {$a cmp $b}f($foo)),"\n\n"; print "t():\n",join("\n",sort {$a cmp $b}t($foo)),"\n\n"; __END__ d(): aa cc dd hh f(): aa cc dd ff hh ii t(): aa cc dd ff hh
--- demerphq
my friends call me, usually because I'm late....
In reply to Re: (Golf) Warningless Comparison
by demerphq
in thread (Golf) Warningless Comparison
by tadman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |