[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-beginners
Subject:    Re: How Can I find all kinds of methods a Object support?
From:       Zapp <zapp.prefect () gmail ! com>
Date:       2012-04-13 8:08:31
Message-ID: 4F87DEFF.90408 () Gmail ! com
[Download RAW message or body]

Finally, It's work! Thanks !

于 2012-4-12 20:11, Michael Rasmussen 写道:
> On Thu, Apr 12, 2012 at 06:29:09PM +0800, Zapp wrote:
> > I had try it, codes is here:
> > 
> > #!/usr/local/bin/perl -w
> > 
> > use Class::Inspector;
> > use IO::File;
> > 
> > my @methods = Class::Inspector->methods('IO::File', 'full', 'public');
> > 
> > print "@methods";
> > 
> > but it Only print this: ARRAY(0xaa4bc8)
> > Why?
> 
> The documentation for Class::Inspector says:
> methods $class, @options
> For a given class name, the "methods" static method will returns ALL the methods \
> available to that class. This includes all methods available from every class up \
> the class' @ISA tree. 
> > > > Returns a reference to an array of the names of all the available methods on \
> > > > success, or "undef" if the class name is invalid or the class is not loaded.
> So you need to assign the return of Class::Inspector->methods to a scalar
> and later defererence the reference.
> You could make these changes:
> 
> my $methods = Class::Inspector->methods('IO::File', 'full', 'public');
> print @$methods;
> # consider print join $/, @$methods;
> 
> and you'll get a list of methods.
> 
> 
> 


-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic