Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Turning on debug/verbosity in modules that are sub-called

by hacker (Priest)
on Feb 25, 2005 at 00:29 UTC ( [id://434324]=perlquestion: print w/replies, xml ) Need Help??

hacker has asked for the wisdom of the Perl Monks concerning the following question:

I've banged my head against the desk so many times this month on this one issue, that there's a dent there now. This SoPW is the result of that frustration hitting me over and over and over.

I seem to be running into a streak of issues where modules that I'm using, are using other modules, which are throwing errors and warnings that I need to debug. I started seeing it with XML::RSS::Tools throwing errors in XML::Parser, several other XML and RSS-related modules, and now moments ago, Net::NNTP is throwing errors down in Net::Cmd.

Here's an example of the errors/warnings I see:

Use of uninitialized value in pattern match (m//) at /usr/local/share/perl/5.8.4/Net/Cmd.pm line 207 (#1)

My code is always run with warnings, diagnostics, and strict.. and for most of my test runs, it runs perfectly clean. Except when it throws these. In this case, it must be something in the article body that Net::Cmd doesn't like, and it errors out.

How can I start flipping on some more-verbose debug in these sub-called modules, if I'm not calling them directly? Some modules support a Debug() method, some do not, so I'm stuck. I don't want to modify the default methods of these modules themselves (i.e. by editing the .pm file).

Is there another way?

Replies are listed 'Best First'.
Re: Turning on debug/verbosity in modules that are sub-called
by borisz (Canon) on Feb 25, 2005 at 01:22 UTC
    a) Use the debugger.
    PERLDB_OPTS="NonStop AutoTrace LineInfo=lines frame=1" perl -d script. +pl less lines
    b) use warnings and not -w, to turn warnings only on in your modul/script.
    c) build some magic around your subs with Hook::LexWrap or a similar module to do something on sub entry or exit.
    Boris
Re: Turning on debug/verbosity in modules that are sub-called
by kvale (Monsignor) on Feb 25, 2005 at 00:52 UTC
    When I have a warning crop up in some module, I usually debug it like any other code. After looking at the code, I insert print statments to see what is going on. If that does not work or for some reason I cannot alter or override a method, the perl debugger is always helpful.

    If you want set a package's verbosity level, just reach in and set that package variable. Sure, it's rude, but it gets the job done :)

    -Mark

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://434324]
Approved by kvale
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found