I've been playing with some of the Devel::* modules lately. I came arross Devel::Carnivore. Here is a small example I put together:
use strict; use warnings; use Devel::Carnivore; my $h; { my %h : Watch('%h'); $h{fname} = "Foo"; $h = \%h; } $h->{lname} = 'Bar'; unwatch $h; $h->{email} = 'foo@bar.com';
and the output:
$perl carnivore.pl # variable is now under observation > %h: "fname" changed from "" to "Foo" at carnivore.pl line 10 > %h: "lname" changed from "" to "Bar" at carnivore.pl line 13 # mission completed
I have several comments: - When we start and stop watching I would like to see the name we assigned to the variable, better yet I'd like to see the real variable name. I would like to be able to control the watching from the outside world. e.g. in .carnivore I would like to say something like script.pl:37:watch %h; so I can run perl -d:Carnivore script.pl and %h will be watched from line 37 of the script.pl file Any idea if I can do this with another module? Maybe with the debugger?

In reply to debugging: tracing changes to hashes by szabgab

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.