更新时间:2023-11-17 14:06:47
什么是@_
?请参见 perldoc -v @_
此外, Class :: Inspector :>
#!/usr/bin/env perl
use strict; use warnings;
use Class::Inspector;
use HTML::TokeParser::Simple;
my $methods = Class::Inspector->methods(
'HTML::TokeParser::Simple', 'full', 'public'
);
print "Methods:\n";
print "$_\n" for @$methods;
print "Superclasses\n";
use Class::ISA;
print join(", ", Class::ISA::super_path('HTML::TokeParser::Simple')), "\n";
In the Perl OOP, how can I dump all methods / fields in this class and its parent class.
my ($self) = @_;
I saw a lot of constructors as above. Then, what is @_
?
I have Java / OOP background. If your explanation can follow Java domain, it will be much easier for me to understand.
What is @_
? See perldoc -v @_
mjd has an interesting article on introspection in Perl.
In addition, How do I list available methods on a given object or package in Perl? answers part of your question.
My preferred answer to that question uses Class::Inspector:
#!/usr/bin/env perl
use strict; use warnings;
use Class::Inspector;
use HTML::TokeParser::Simple;
my $methods = Class::Inspector->methods(
'HTML::TokeParser::Simple', 'full', 'public'
);
print "Methods:\n";
print "$_\n" for @$methods;
print "Superclasses\n";
use Class::ISA;
print join(", ", Class::ISA::super_path('HTML::TokeParser::Simple')), "\n";