It's not perfect, but here's a hack on Devel::Trace I once threw together:

package Devel::Trace; $VERSION = '0.10'; $TRACE = 1; $REGEX = qr//; # This is the important part. The rest is just fluff. sub DB::DB { return unless $TRACE; my ( $p, $f, $l ) = caller; my $code = \@{"::_<$f"}; my $line = ">> $f:$l: $code->[$l]"; print STDERR $line if $line =~ $REGEX; } sub import { my $package = shift; while ( defined( $_ = shift @_ ) ) { if ( $_ eq 'trace' ) { my $caller = caller; *{ $caller . '::trace' } = \&{ $package . '::trace' }; } elsif ( $_ eq 'match' ) { my $regex = shift; $REGEX = qr/$regex/; } else { use Carp; croak "Package $package does not export `$_'; aborting"; } } } my %tracearg = ( 'on' => 1, 'off' => 0 ); sub trace { my $arg = shift; $arg = $tracearg{$arg} while exists $tracearg{$arg}; $TRACE = $arg; } 1;

That's "not ready for prime time", but now I can do this:

perl -d:Trace=match,some_regex some_prog.pl 2>logfile

And only lines which match the regex are printed. That's handy if you want to limit it to a particular package. It's not perfect, but it was a good enough hack to let me see a nasty execution flow error that I was having trouble following in the debugger (the debugger can be a right pain to use with interactive programs).

You could probably start hacking in this to get something closer to what you want.

Cheers,
Ovid

New address of my CGI Course.


In reply to Re: Debug Macro by Ovid
in thread Debug Macro by Outaspace

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.