Re: How do I retrieve the 'type' of an object

On Sun, 2004-06-06 at 18:32, Daniel Kasak wrote:
I'm looping through a set of objects, and I want to get the type of 
object, ( eg GtkEntry ) and then decide what to do based on the type.
How do I do that?

    foreach my $field (@{$self->{fieldlist}}) {
        my $widget = $self->{form}->get_widget($field);
        # Need to figure out what type of object $widget is

the perl ref function/operator should do the trick:

my $button = Gtk2::Button->new ('Click _Me');
print '$button's type is: '.(ref $button)."\n";


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