And here's .perldb to watch %h as noted:use strict; use warnings; my $h; { my %h; # watch from here ... $h{fname} = "Foo"; $holder = \%h; } $holder->{lname} = 'Bar'; $holder->{email} = 'foo@bar.com'; # ... to before here
Run this as perl -d <your program>. The output:push @DB::typeahead, (split /\n/, <<EOS); # Load Carnivore use Devel::Carnivore # Line to start watching on c 7 watch(\\%h) # run to point where we want to switch off c 13 # do so unwatch \$h # run to end of program c # quit debugger q EOS
The problem, of course, is that you're dependent on line numbers, but there's an example of how to automate the debugger. Removing the comments will of course give you nicer output as well.01:26 PM $ perl5.8.5 -d z.pl Loading DB routines from perl5db.pl version 1.27 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(z.pl:4): my $h; main::(z.pl:5): { auto(-12) DB<1> use Devel::Carnivore auto(-11) DB<2> # Line to start watching on auto(-10) DB<3> c 7 main::(z.pl:7): $h{fname} = "Foo"; auto(-9) DB<4> watch(\%h) # variable is now under observation auto(-8) DB<5> # run to point where we want to switch off auto(-7) DB<6> c 13 > "fname" changed from "" to "Foo" at z.pl line 7 > "lname" changed from "" to "Bar" at z.pl line 11 main::(z.pl:13): $h->{email} = 'foo@bar.com'; # ... to before her +e auto(-6) DB<7> # do so auto(-5) DB<8> unwatch $h # mission completed auto(-4) DB<9> # run to end of program auto(-3) DB<10> c Debugged program terminated. Use q to quit or R to restart, use O inhibit_exit to avoid stopping after program termination, h q, h R or h O to get additional info. auto(-2) DB<10> # quit debugger auto(-1) DB<11> q 01:26 PM $
In reply to Automating the debugger with Devel::Carnivore
by pemungkah
in thread debugging: tracing changes to hashes
by szabgab
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |