in reply to Re: Changing every subroutine in many perl scripts
in thread Changing every subroutine in many perl scripts
Okay, so I tried the following code:
#!/usr/bin/perl use warnings; use strict; use Hook::LexWrap; my @mars_subs = qw (add increment); for (@mars_subs) { wrap $_, pre => sub { my @caller = caller(0); for (@caller) { print $_, " " if defined $_; } print "\n"; }; } print add( 1, 2 ), "\n"; sub add { my ( $num1, $num2 ) = @_; increment($num1); return $num1 + $num2; } sub increment { my $num = shift; return ++$num; }
And the output I got is:
main hooklexwrap.pl 17 main::__ANON__ 1 1 1794 UUUUUUUUUUUUU main hooklexwrap.pl 21 main::__ANON__ 1 1538 UUUUUUUUUUUUU 3
How do I get the actual sub names like main::add instead of main::__ANON__ ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Changing every subroutine in many perl scripts
by chromatic (Archbishop) on Jul 26, 2012 at 05:55 UTC | |
by nitin1704 (Sexton) on Jul 26, 2012 at 09:06 UTC |