in reply to Re: Re: Re: (Golf) Warningless Comparison
in thread (Golf) Warningless Comparison

And here's what you get if you comment out your signal handler.

NOTE: NO WARNINGS from my original entry.

I hade to comment out your implementation of tadman's solution because if wouldn't compile.

I think the problem lies in your signal handler rather than my code. I specifically disable the warnings where I accept they will occur using the standard Perl mechanism of local $^W=0;

Your signal handler converts a SIG_WARN into a SIG_INT (die) which kind of belies the reasons for Perl distinguishing between them.

If you change the rules of Formula 1 to have a mandatory water section and then enter in a D.U.K.W., you'll likely win every race.

use warnings; use strict; use Carp; #local $SIG{__WARN__}=sub {die("\t@{[(caller(1))[3]]}() generated warn +ings!\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 }, # commented out because of rules . 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 sub ukg{local$^W=0;my$a=pop;grep{!exists$a->{$_}{O}or$a->{$_}{O}ne$a-> +{$_}{C}}keys%$a} #85 sub ukf{local($^W,$a)=(0,pop);grep{!exists$a->{$_}{O}or$a->{$_}{O}ne$a +->{$_}{C}}keys%$a} #87 sub ukh{$^W=0;$a=pop;grep{!exists$a->{$_}{O}or$a->{$_}{O}ne$a->{$_}{C} +}keys%$a} print " Required: aa cc dd ff hh 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 $@; eval { print " browserUk f(): @{[sort {$a cmp $b} ukf($foo)]}\n"; }; print $@ if $@; eval { print " browserUk g(): @{[sort {$a cmp $b} ukg($foo)]}\n"; }; print $@ if $@; eval { print " browserUk h(): @{[sort {$a cmp $b} ukh($foo)]}\n"; }; print $@ if $@; __END__ 21:07:50.19 C:\test>201598 Required: aa cc dd ff hh jj kk ll mm ------------------------------------------ Undefined subroutine &main::tad called at C:\test\201598.pl line 35. Use of uninitialized value in string ne at C:\test\201598.pl line 22. Use of uninitialized value in string ne at C:\test\201598.pl line 22. Use of uninitialized value in string ne at C:\test\201598.pl line 22. Use of uninitialized value in string ne at C:\test\201598.pl line 22. Use of uninitialized value in string ne at C:\test\201598.pl line 22. Use of uninitialized value in string ne at C:\test\201598.pl line 22. Use of uninitialized value in string ne at C:\test\201598.pl line 22. BrowserUK golf: aa cc dd ff hh jj kk ll mm 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 jj kk ll mm Use of uninitialized value in string ne at C:\test\201598.pl line 30. Use of uninitialized value in string ne at C:\test\201598.pl line 30. Use of uninitialized value in string ne at C:\test\201598.pl line 30. Use of uninitialized value in string ne at C:\test\201598.pl line 30. Use of uninitialized value in string ne at C:\test\201598.pl line 30. Use of uninitialized value in string ne at C:\test\201598.pl line 30. Use of uninitialized value in string ne at C:\test\201598.pl line 30. browserUk f(): HASH(0x1bd5534) HASH(0x1bd5594) HASH(0x1bd55f4) HASH(0 +x1bd5654) HASH(0x1bd569c) HASH(0x1bd56fc) HASH(0x1bd575c) HASH (0x1bdf0dc) HASH(0x1bdf1c0) HASH(0x1d1f664) HASH(0x1d1f6ac) HASH(0x1d1 +f6f4) HASH(0x1d1f73c) HASH(0x1d1f784) HASH(0x1d1f7cc) HASH(0x1 d1f814) HASH(0x1d231cc) HASH(0x1d23214) HASH(0x1d2325c) HASH(0x1d2328c +) HASH(0x1d232d4) HASH(0x1d241e8) HASH(0x1d243c8) HASH(0x1d244 c4) aa cc dd ff hh jj kk ll mm Use of uninitialized value in string ne at C:\test\201598.pl line 29. Use of uninitialized value in string ne at C:\test\201598.pl line 29. Use of uninitialized value in string ne at C:\test\201598.pl line 29. Use of uninitialized value in string ne at C:\test\201598.pl line 29. Use of uninitialized value in string ne at C:\test\201598.pl line 29. Use of uninitialized value in string ne at C:\test\201598.pl line 29. Use of uninitialized value in string ne at C:\test\201598.pl line 29. browserUk g(): HASH(0x1bd5534) HASH(0x1bd5594) HASH(0x1bd55f4) HASH(0 +x1bd5654) HASH(0x1bd569c) HASH(0x1bd56fc) HASH(0x1bd575c) HASH (0x1bdf0dc) HASH(0x1bdf1c0) HASH(0x1d1f664) HASH(0x1d1f6ac) HASH(0x1d1 +f6f4) HASH(0x1d1f73c) HASH(0x1d1f784) HASH(0x1d1f7cc) HASH(0x1 d1f814) HASH(0x1d231cc) HASH(0x1d23214) HASH(0x1d2325c) HASH(0x1d2328c +) HASH(0x1d232d4) HASH(0x1d241e8) HASH(0x1d243c8) HASH(0x1d244 c4) aa cc dd ff hh jj kk ll mm Use of uninitialized value in string ne at C:\test\201598.pl line 31. Use of uninitialized value in string ne at C:\test\201598.pl line 31. Use of uninitialized value in string ne at C:\test\201598.pl line 31. Use of uninitialized value in string ne at C:\test\201598.pl line 31. Use of uninitialized value in string ne at C:\test\201598.pl line 31. Use of uninitialized value in string ne at C:\test\201598.pl line 31. Use of uninitialized value in string ne at C:\test\201598.pl line 31. browserUk h(): HASH(0x1bd5534) HASH(0x1bd5594) HASH(0x1bd55f4) HASH(0 +x1bd5654) HASH(0x1bd569c) HASH(0x1bd56fc) HASH(0x1bd575c) HASH (0x1bdf0dc) HASH(0x1bdf1c0) HASH(0x1d1f664) HASH(0x1d1f6ac) HASH(0x1d1 +f6f4) HASH(0x1d1f73c) HASH(0x1d1f784) HASH(0x1d1f7cc) HASH(0x1 d1f814) HASH(0x1d231cc) HASH(0x1d23214) HASH(0x1d2325c) HASH(0x1d2328c +) HASH(0x1d232d4) HASH(0x1d241e8) HASH(0x1d243c8) HASH(0x1d244 c4) aa cc dd ff hh jj kk ll mm

Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: (Golf) Warningless Comparison
by demerphq (Chancellor) on Sep 29, 2002 at 20:35 UTC
    NOTE: NO WARNINGS from my original entry.

    Nope. Did you look at what was on line 22?

    Use of uninitialized value in string ne at C:\test\201598.pl line 22. BrowserUK golf: aa cc dd ff hh jj kk ll mm
    I hade to comment out your implementation of tadman's solution because if wouldn't compile.

    Weird, it compiles here. Are you sure it didnt get screwed on download or something?

    Your signal handler converts a SIG_WARN into a SIG_INT (die) which kind of belies the reasons for Perl distinguishing between them.

    This has nothing to do with why your code generates warnings when you think it shouldnt.

    Let this whole thing be a lesson to you: -w and $^W should as the documentation says be avoided!

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