Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^5: Do people find warning for undef with string compare useful?

by vsespb (Hermit)
on Jun 01, 2013 at 15:28 UTC ( #1036461=note: print w/ replies, xml ) Need Help??


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

"catching an error", and handling it -- ideally would involve invoking an alternate method to do what you were trying to do
have programs that collect status information, and if something is wrong, they take steps to fix it -- progressively, as well as send email at increasing intervals
Well, In my example you see 1) a typo 2) "confess" method. This means I catch programmer's error (i.e. it's an assertion).
you are trying to change the nature of the discussion
Okay, show me your real code where you need work with undefs..


Comment on Re^5: Do people find warning for undef with string compare useful?
Re^6: Do people find warning for undef with string compare useful?
by perl-diddler (Hermit) on Jun 02, 2013 at 05:24 UTC
    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?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1036461]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2014-12-25 04:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls