Perl debugger in Perl script hierarchy

Discussion in 'Perl Misc' started by Volker Nicolai, Jul 29, 2004.

  1. 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
     
    Volker Nicolai, Jul 29, 2004
    #1
    1. Advertising

  2. Volker Nicolai

    Paul Lalli Guest

    On Thu, 29 Jul 2004, Volker Nicolai wrote:

    > 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
     
    Paul Lalli, Jul 29, 2004
    #2
    1. Advertising

  3. Volker Nicolai wrote:
    > 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
     
    Jürgen Exner, Jul 29, 2004
    #3
  4. Volker Nicolai

    Peter Scott Guest

    In article <>,
    (Volker Nicolai) writes:
    >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'.

    --
    Peter Scott
    http://www.perldebugged.com/
    *** NEW *** http://www.perlmedic.com/
     
    Peter Scott, Jul 29, 2004
    #4
  5. [A complimentary Cc of this posting was sent to
    Volker Nicolai
    <>], who wrote in article <>:
    > 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
     
    Ilya Zakharevich, Aug 2, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wet Basement
    Replies:
    1
    Views:
    2,529
    BobMonk
    Jul 15, 2003
  2. dpackwood
    Replies:
    3
    Views:
    1,812
  3. Jim Cain
    Replies:
    2
    Views:
    154
    Jim Cain
    Jan 21, 2008
  4. Robert Oschler
    Replies:
    1
    Views:
    224
    Mcginkel
    Sep 5, 2005
  5. aflat362
    Replies:
    7
    Views:
    221
    naixn
    Dec 7, 2006
Loading...

Share This Page