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"; }; }
In reply to Analyzing Perl Code by nitin1704
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |