I went and updated your code to incorporate my solutions, and in the process added a bunch of cases. Unfortunately this also caused your solution to generate warnings. I find it a touch suprising that my longer solution is the only one that works correctly on all the cases. Guys youve got to be more thorough in your testing!
use warnings; use strict; use Carp; local $SIG{__WARN__}=sub {die("\t@{[(caller(1))[3]]}() generated warni +ngs!\n")}; 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 }, # jj => { O => 0, C => ' ' }, # kk => { O => ' ', C => 0 }, # ll => { O => undef, C => ' ' }, # mm => { O => ' ', C => undef }, # }; sub BUK{local($^W,$a)=(0,pop);grep{!exists$a->{$_}{O}or$a->{$_}{O}ne$a +->{$_}{C}}keys%$a} sub snw{no warnings qw(uninitialized);my$h=pop;grep{$h->{$_}{O}ne$h->{ +$_}{C}}keys %$h} sub sg_{my$h=pop;grep{!(defined($h->{$_}{O}&&$h->{$_}{C})&&$h->{$_}{O} +eq$h->{$_}{C}||!defined($h->{$_}{O}||$h->{$_}{C}))}%$h} sub eg_{my$h=pop;grep{!(($h->{$_}{O}||$;)eq($h->{$_}{C}||$;))}%$h} sub ddf{$a=pop;grep{$b=$$a{$_};defined$$b{O}!=defined$$b{C}||defined$$ +b{O}&&$$b{O}ne$$b{C}}keys%$a}#98 sub dex{$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}#126 sub tad{my($h)=@_;grep{!exists($h->{$_}->{O})||(defined($h->{$_}->{O}) +?(defined($h->{$_}->{C})?($h->{$_}->{O}ne$h->{$_}->{C}):1):defined($h +->{$_}->{C}))}keys%$h}#162 print " Required: aa cc dd ff hh ii jj kk ll mm\n"; print "---------------------------------------------\n"; eval { print " tadman golf: @{[sort {$a cmp $b} tad($foo)]}\n"; }; print $@ if $@; eval { print "BrowserUK golf: @{[sort {$a cmp $b} BUK($foo)]}\n"; }; print $@ if $@; eval { print "sauoq No warns: @{[sort {$a cmp $b} snw($foo)]}\n"; }; print $@ if $@; eval { print " Sauoq golf: @{[sort {$a cmp $b} sg_($foo)]}\n"; }; print $@ if $@; eval { print " Elusion golf: @{[sort {$a cmp $b} eg_($foo)]}\n"; }; print $@ if $@; eval { print " Demerphq defd: @{[sort {$a cmp $b} ddf($foo)]}\n"; }; print $@ if $@; eval { print "Demerphq exist: @{[sort {$a cmp $b} dex($foo)]}\n"; }; print $@ if $@; __END__ Required: aa cc dd ff hh ii jj kk ll mm --------------------------------------------- tadman golf: aa cc dd ff hh jj kk ll mm main::BUK() generated warnings! sauoq No warns: aa cc dd hh jj kk ll mm Sauoq golf: aa cc dd hh jj kk ll mm Elusion golf: aa cc dd jj kk ll mm Demerphq defd: aa cc dd hh jj kk ll mm Demerphq exist: aa cc dd ff hh ii jj kk ll mm
Hmm, maybe it isnt so suprising considering its the longest with the exception of only tadmans solution

;-)

---
demerphq
my friends call me, usually because I'm late....


In reply to Re: Re: (Golf) Warningless Comparison by demerphq
in thread (Golf) Warningless Comparison by tadman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.