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

Hello Guys I am very, very new to perl so forgive if this sounds like a stupid question. Is there a way to set up a watch in perl similar to VB or to Cobol? Basically I am trying to watch the data as it moves thru the program. If there is a way to do this, can you please telll me how. Thanks

Replies are listed 'Best First'.
Re: Watch in Debug
by ferrency (Deacon) on Aug 03, 2000 at 22:17 UTC
    You probably want to check out the Perl debugger. man perldebug if you're on a unix-like system; otherwise find "perldebug" in your perl documentation.

    Basic idea:

    perl -d my_perl_program
    You can then set breakpoints, watch expressions (with the W command), trace through the program, and so on. The docs have the details.

    Alan

Re: Watch in Debug
by maverick (Curate) on Aug 03, 2000 at 22:19 UTC
    Perl has builtin(?) debugger. perl -d runs the script in the debugger. You might want to check out ddd if you're on a Unix type system (http://www.gnu.org/sorfware/ddd/). It's a GUI debugging package that has support for perl

    /\/\averick

Re: Watch in Debug
by chip (Curate) on Aug 03, 2000 at 23:56 UTC

    Tied variables can help here. Check out Tie::Watch on CPAN.

        -- Chip Salzenberg, Free-Floating Agent of Chaos

Re: Watch in Debug
by Cirollo (Friar) on Aug 03, 2000 at 22:22 UTC
    Not sure if this is exactly what you want, but you can set an action to happen before each debugger prompt with the "<" command.

    So, supposing you wanted to watch $foo, you could say
    < print "foo is $foo\n";

    If you want to set a multiple-line command to run, put backslashes at the end of the lines to continue to another line.

    Update: ferrency's method works much better :) Anybody know why 'W' doesn't seem to be in Perl in a Nutshell? Wish I had known about that earlier....

RE: Watch in Debug
by Anonymous Monk on Aug 03, 2000 at 22:31 UTC
    Thanks guys I really appreciate the help... I will be asking you questions on regular basis. Again Thanks.
      hey dude, if you're gonna ask us questions, log in, create an account, talk, post answers, or just questions... become part of the community... we're all growing and learning here!