Perl debugger in Perl script hierarchy

V

Volker Nicolai

Hi,

I have a huge bunch of Perl scripts which invoke each other mainly
by the system command (just have to use them, did not write the
stuff myself).

First question: Isn't there a better way to make a hierarchy of
Perl scripts than to use system("sub_script") again and again?

Second question: I tried to debug the beast :) but the problem
is that the debug switch -d which I have set e.g. in the
first/upmost script gets "lost" as soon as the system command
executes a subscript. That in general seems sort of reasonable
to me but then how can I overcome the problem that the debugger
does not stop in this invoked sub script (I mean except setting
the -d flag in each of the 100 sub scripts which is a problem
if I do not want to use the debugger any more - tried it with
the 1st sub hierarchy, seems to work).

Third question: Logically in the top script I can not see the
subroutines of the sub scripts before I dive into them.
What can I do to tell the debugger to stop @ a certain
subroutine deep down in the hierarchy. I tried to use
$DB::single = 1 / 2 respectively and
$DB::signal = 1
but the bloody thing does not care :-\.
This is probably related to questions 2:
No debugger activation no stopping, correct?

Final question: Is there any debugger documentation
where problems like these are covered?

Thanks for any contribution.
Volker


Volker Nicolai
Philips Semiconductors
Hamburg, Germany
 
P

Paul Lalli

Hi,

I have a huge bunch of Perl scripts which invoke each other mainly
by the system command (just have to use them, did not write the
stuff myself).

First question: Isn't there a better way to make a hierarchy of
Perl scripts than to use system("sub_script") again and again?

Yes. For simplicity, try using 'do' instead of system. Read about it at
perldoc -f do

The really canonical way to do this is using modules, however. If you're
ready to get your feet wet, read some documentation on 'use', 'require',
and the host of module documentation available from perldoc.
Second question: I tried to debug the beast :) but the problem
is that the debug switch -d which I have set e.g. in the
first/upmost script gets "lost" as soon as the system command
executes a subscript.

This will be fixed when you use 'do' instead of 'system'

Third question: Logically in the top script I can not see the
subroutines of the sub scripts before I dive into them.
What can I do to tell the debugger to stop @ a certain
subroutine deep down in the hierarchy.

use modules. :)
I tried to use
$DB::single = 1 / 2 respectively and
$DB::signal = 1
but the bloody thing does not care :-\.
This is probably related to questions 2:
No debugger activation no stopping, correct?

Final question: Is there any debugger documentation
where problems like these are covered?

I've not tried searching for such things.


Paul Lalli
 
J

Jürgen Exner

Volker said:
I have a huge bunch of Perl scripts which invoke each other mainly
by the system command (just have to use them, did not write the
stuff myself).

Ouch, what a concept!
First question: Isn't there a better way to make a hierarchy of
Perl scripts than to use system("sub_script") again and again?

Absolutely. Use modules (perldoc -f use, perldoc -f require, perldoc
perlmod).

Then the problems indicated by your other questions will pretty much vanish.

jue
 
P

Peter Scott

Second question: I tried to debug the beast :) but the problem
is that the debug switch -d which I have set e.g. in the
first/upmost script gets "lost" as soon as the system command
executes a subscript. That in general seems sort of reasonable
to me but then how can I overcome the problem that the debugger
does not stop in this invoked sub script (I mean except setting
the -d flag in each of the 100 sub scripts which is a problem
if I do not want to use the debugger any more - tried it with
the 1st sub hierarchy, seems to work).

Set the environment variable PERL5OPT to '-d'.
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was sent to
Volker Nicolai
Second question: I tried to debug the beast :) but the problem
is that the debug switch -d which I have set e.g. in the
first/upmost script gets "lost" as soon as the system command
executes a subscript.

env PERL5OPTS=-d perl -S yourscript

(but make sure that you are using xterm or somesuch, so that kids are
controlled from different windows).
Third question: Logically in the top script I can not see the
subroutines of the sub scripts before I dive into them.
What can I do to tell the debugger to stop @ a certain
subroutine deep down in the hierarchy.

The debugger writes a configuration file; you may program it from this
file; in particular, force it to set breakpoints (using the whole
power of Perl, in particular, you can make it conditional on the name
of the script, etc).

All this power is there. However, as other replies indicate, these
solutions are for different problems. In your case, just use modules.

Hope this helps,
Ilya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top