in reply to Re^5: Do people find warning for undef with string compare useful?
in thread Do people find warning for undef with string compare useful?

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?

  • Comment on Re^6: Do people find warning for undef with string compare useful?
  • Download Code