Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Taking a part a Perl Object.

Reply
Thread Tools

Taking a part a Perl Object.

 
 
Nene
Guest
Posts: n/a
 
      06-25-2012
Hi,
I've been tasked to learn the behavior of a complicated homegrown Perl
module.

Are there any resources on how to to take a part a perl module, in
particular the 'new' object?

I want to learn the guts of the 'new' object, would the perl debugger
be a good start?

Nene
 
Reply With Quote
 
 
 
 
Marc Girod
Guest
Posts: n/a
 
      06-26-2012
On Jun 26, 12:49*am, Ben Morrow <b...@morrow.me.uk> wrote:

> Personally I don't find the Perl debugger terribly useful. However, it
> may be more so when trying to decipher code you don't yet understand.


On the contrary, I use the debugger a lot. I find it useful to place
breakpoints, inspect the trace and the values of the variables.
Possibly use only the 'action' function (usually print, but sometimes
modify).

Marc
 
Reply With Quote
 
 
 
 
Rainer Weikusat
Guest
Posts: n/a
 
      06-26-2012
Ben Morrow <> writes:
> Quoth Nene <>:


[...]

>> I want to learn the guts of the 'new' object, would the perl debugger
>> be a good start?

>
> Reading the source, carefully, would be a good start. Once you think you
> have an idea how the module works, write little programs that call a
> function or two, and see if they do what you expected: forming theories
> which you can then test is a much more efficient way of finding things
> out than trying things aimlessly. If necessary you can insert 'warn'
> statements (or something else appropriate) here and there to print out
> important variables, and to see where the control goes.


I suggest the same thing: If you don't understand the actual control
flow, try to catch it with subsequently more specific "does it pass
here?" ad hoc diagnostics, possibly printing other values of interest
while having the source code loaded in a reasonable editor.

In my experience, that's a lot faster and more convenient than trying
to single-step through large bodies of code. You never want to know
everything. It also works in situations where 'stop the world to
inspect its state' isn't possible.
 
Reply With Quote
 
Nene
Guest
Posts: n/a
 
      06-26-2012
On Jun 25, 7:49*pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth Nene <rodbas...@gmail.com>:
>
> > I've been tasked to learn the behavior of a complicated homegrown Perl
> > module.

>
> I suppose it's futile to ask if the module is documented or commented
> properly?


It is documented but very vaguely.

> If there is a test suite, so you can get some idea of how the
> author intended it to be used?


Yes, the author has test scripts which I made copies of and made them
smaller tests. Once I understand the rudiments
of the module ( a REST API, btw ). I will use his personal tests.
> Do you at least have examples of programs
> which successfully use the module?
>
> > Are there any resources on how to to take a part a perl module, in
> > particular the 'new' object?

>
> 'new' is usually a method.


Thank you clarifying that. What I have learned from the new method,
correct me if I am wrong, that it is the vehicle to obtain
the data required for the purpose of the module and the methods are
there to do whatever you want with the data.
>
> > I want to learn the guts of the 'new' object, would the perl debugger
> > be a good start?

>
> Reading the source, carefully, would be a good start. Once you think you
> have an idea how the module works, write little programs that call a
> function or two, and see if they do what you expected: forming theories
> which you can then test is a much more efficient way of finding things
> out than trying things aimlessly. If necessary you can insert 'warn'
> statements (or something else appropriate) here and there to print out
> important variables, and to see where the control goes.


Thank you so much for this advice. I have inserted print statements
all over the place and what I have learned that
90% of all the data are obtained through hash references.

>
> Write things down as you go, so you don't forget them. If there isn't
> any documentation, it would be a good idea to start writing it:


I made a copy of the pm file with the print statements and added
comments to the file, this file will be my reference file.
Every time I fire up the tests, it will print comments, sort of like a
review each time I use it.

> exercise should help you form a clearer picture of what the code is
> trying to accomplish, and how. Add comments to any bit of code that are
> particularly obscure.
>
> Personally I don't find the Perl debugger terribly useful. However, it
> may be more so when trying to decipher code you don't yet understand.
>
> Ben


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HMS Victory in 1:48 scale - Part 3 & Part 4 Alexander Blokhin Digital Photography 0 12-23-2009 10:11 AM
Editorial: Taking the SLI Plunge – Part 2 @ Virtual-Hideout Silverstrand Front Page News 0 02-20-2006 10:35 PM
ActiveX apologetic Larry Seltzer... "Sun paid for malicious ActiveX code, and Firefox is bad, bad bad baad. please use ActiveX, it's secure and nice!" (ok, the last part is irony on my part) fernando.cassia@gmail.com Java 0 04-16-2005 10:05 PM
Easy part done, now the hard part!! jollyjimpoppy A+ Certification 0 09-10-2003 10:37 AM
Difference in module_eval taking block vs. taking string (1.8 bug?) Jim Cain Ruby 1 07-18-2003 02:01 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57