Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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

by vsespb (Chaplain)
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?

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1036461]
[erix]: still doesn't work?
[afoken]: sorry, forget File::BOM. I did not see DBD.
[ELISHEVA]: perldoc - of course
[erix]: hm, where's tux when you need him?
[ELISHEVA]: what's curiouser is that the underlying Text::CSV_XS appears to be BOM-friendly
[afoken]: DBD::CSV has a csv_class attribute. You could subclass Text::CSV_XS to handle BOMs, e.g. through File::BOM.
[ELISHEVA]: Text::CSV_XS already can handle boms - see its detect_bom flag
[ELISHEVA]: but it seems that the DBD::CSV layer on top of it doesn't
[afoken]: Also: All other attributes that start with csv_ and are not described above will be passed to Text::CSV_XS (without the csv_ prefix).
[Discipulus]: what about a good 'ol SOPW?

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2017-05-28 20:26 GMT
Find Nodes?
    Voting Booth?