Welcome to the Monastery | |
PerlMonks |
Re^2: Inspection/Introspectionby particle (Vicar) |
on Jun 22, 2002 at 22:03 UTC ( [id://176540]=note: print w/replies, xml ) | Need Help?? |
Unfortunately since there's no such thing as named parameters in Perl there's no real way to find out about a function's parameters either.true, and false! there are no named params in perl 5 (they're coming in perl 6.) you can find out about a function's parameters, though. use Devel::TraceSubs, my first cpan module (you'll have to install Hook::LexWrap first.) you specify namespaces in which you want to trace the subroutines, it reports in text or wrapped (read html) format. optionally, you can see the parameters passed to the subs. version 0.01 prints only scalars, so you won't see data inside references. you can see the stack depth for each call, and figure out how each piece of code relates to the rest. i'm working on changes (thanks to Jenda,) which i hope to put in version 0.02 (this weekend?) you'll be able to see params passed through Data::Dumper, and sub entry/exit timestamps. it will also fix some other bugs related to modules it's not allowed to trace (Carp, Data::Dumper, and any others i find.) oh, and i think you'll be better able to solve your overall problem by reading up on refactoring. Martin Fowler's book "Refactoring: Improving the Design of Existing Code", web site, buy it is a really good one. in case you don't get a chance to read it, i'll give you a few hints: don't refactor and add functionality at the same time, and take small steps. read the book, it's tremendous.
~Particle *accelerates*
In Section
Seekers of Perl Wisdom
|
|