[Israel.pm] getting class methods

Issac Goldstand margol at beamartyr.net
Tue Aug 10 12:41:15 PDT 2004


    my $class="Some::Class"; # (or use __PACKAGE__, or ref($proto)||$proto,
etc )
    my $name;
    for $name (
        # Keep if this is a defined subroutine in this class.
        grep { defined &{ ${"${class}::"}{$_} } }
             # Extract from all the symbols in this class.
             sort keys %{"${class}::"}
      ) {
        # If we printed this already, skip it.
        next if $seen{$name}++;
        print "Found $name\n";
     }

  Yitzchak

PS.  I cheated.
Two points for whomever can explain that.

----- Original Message ----- 
From: "Itamar Elem" <elem at compugen.co.il>
To: <perl at perl.org.il>
Sent: Tuesday, August 10, 2004 5:27 PM
Subject: [Israel.pm] getting class methods


> hi
>
> given instance of class or class name  how can i get all the methods
belonging to this instance/class
>
> thank
> itamar
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl
>




More information about the Perl mailing list