in reply to Do not use UNIVERSAL::isa this way; but why?

Thank you all for your answers!

Well then... I think I'll 'switch' to
$is_my_class = defined($object) && $object->isa('My::Class');
since I used to write
$is_my_class = defined($object) && $UNNIVERSAL::isa($object, 'My::Clas +s');
or
$is_my_class = eval { $fd->isa('My::Class') };
to preserve my keyboard! ;)

@ Tanktalus: uh... I've never thought about this. But I think I... yeah... the time will come when I'll have to write a Decorator! At least this came to my mind when I read your post.

k

Replies are listed 'Best First'.
Re^2: Do not use UNIVERSAL::isa this way; but why?
by klekker (Pilgrim) on Dec 11, 2008 at 08:32 UTC
    *narg*
    Typo respectively wrong. I won't use
    $is_my_class = defined($object) && $object->isa('My::Class');
    because if $object is defined but not blessed...

    I'll use
    $is_my_class = eval { $fd->isa('My::Class') };
    although normally (and I don't know why) I try to avoid 'eval'.
    And although I'm not sure if I like this statement.
    k