Where I ***need*** work with undefs? I call strawman!!! ;-)

Though, seriously, just earlier today...

sub same_subnet ($) { my $p = shift; my $net = $_[0]; RefCheck($net, __PACKAGE__); TPe "ptype=%s, netptype=%s", $p->{ptype}, $net->{ptype} unless $p->{ptype} && $net->{ptype}; return undef if $p->{ptype} ne $net->{ptype}; <<<----
The line with the arrow next to it threw out warnings because it got passed down the wrong stuff. But it didn't help me find the problem sooner. First I added the TestPrintErr statement to see which one was undef (Perl didn't tell me). Then I wondered if I should put in a check for undef there, .... had one there, until I realized it can't happen unless something was broken upstream.

All it needed to do was tell me that it didn't match -- it didn't need to die w/a warning. I would rather it have returned the undef, so the upper level routines would have pointed at the place in the code that was generating the undefs that got passed down to this level. Still don't know if I need the overhead of the refcheck statement (it dies on wrong typeref).

That's about the best I can come up with on the spur of the moment, but 'need'... come on now!!!... Mighten the above pass for a reasonable place where it's more of a pain than not -- especially since the upper level routine that calls this one was the one that had the error and the one that got back all the 'undef's from interfaces that should have matched.

Does it pass for an example?


In reply to Re^6: Do people find warning for undef with string compare useful? by perl-diddler
in thread Do people find warning for undef with string compare useful? by perl-diddler

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.