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-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to