No such thing as a small change | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I often have the same problem with objetcs, stuff like: $elt->first_child->text in an XML tree, which crashes if $elt has no first child. In that case I would like to get just undef, but I still want to be able to test $elt->first_child and have it return a false value when there is no first_child. As a good monk the nicest solution would be to bless something false! A false value lessed into the appropriate object class would work just fine. Of course you can't do that! Traces of Larry's religious faith I guess... So the next solution I see is to create a new pragma, something like use default_undef_methods which would just default methods on undef objects to undef. I'll get to it as soon as I've got a minute! Would that solve your problem? In reply to RE: undefs and functions
by Anonymous Monk
|
|