http://nitingargblog.wordpress.com/2012/09/16/ocean-of-perls
Basically, I wanted to add trace statements at the beginning of a script, and also when its constituent subroutines are called. I tried three approaches for that:
3. Hook::LexWrap Module: Adding pre-wrappers to subroutines:for my $child ( $sub->children ) { $child->start->add_content($caller) if ref $child eq "PPI::Structure::Block"; }
my @all_subs = qw (sub1 sub2); for my $sub (@all_subs) { wrap $sub, pre => sub { print "Calling '$sub' in file: $0\n"; }; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Analyzing Perl Code
by toolic (Bishop) on Sep 18, 2012 at 14:50 UTC | |
by nitin1704 (Sexton) on Sep 18, 2012 at 16:59 UTC | |
by Jenda (Abbot) on Sep 19, 2012 at 00:06 UTC | |
by nitin1704 (Sexton) on Sep 19, 2012 at 14:48 UTC | |
by Jenda (Abbot) on Sep 19, 2012 at 21:45 UTC | |
by davido (Cardinal) on Sep 18, 2012 at 17:43 UTC | |
|
Re: Analyzing Perl Code
by BrowserUk (Patriarch) on Sep 19, 2012 at 23:02 UTC | |
|
Re: Analyzing Perl Code
by talexb (Chancellor) on Sep 19, 2012 at 12:02 UTC | |
by Your Mother (Archbishop) on Sep 20, 2012 at 15:44 UTC |