Re: How to get the Class name of an element



Dave Hayes <dave jetcafe org> writes:

  if (ref($text) eq 'Gtk2::Entry') {

I expect isa() is friendlier to subclasses, though wouldn't matter
within a self-contained spot of code as such.

A bit of a grep shows eq instead of isa in a few modules in cpan.  I see
with some embarrassment one of mine too! :-)  Maybe a perlcritic check
could advise against it, in general ...

The other ways to do it of course include ->can('foo') to see if the
method you think you want is possible, or ->find_property('foo') for a
possible object property of interest.


-- 
"What's that Bublé character got that I haven't got?"



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]