in reply to Using caller to determine the namespace of an anonymous subroutine
As an alternate to what chromatic said, I have found the Sub::Name module to be very helpful in these kinds of situations (I used it in my module Class::MOP, whenever I am adding a method to a class). Again, it needs to be within the code for Creator::create, but IMO it is much less "magical".
After this, not only will the sub show up correctly in the output of caller(), but is also shows up correctly when you poke at it with any of the B modules too. This is because Sub::Name will actually set the STASH and NAME attributes for the CV itself using XS.my $full_name = $caller."::".$field; *{$fullname} = Sub::Name::subname $full_name => sub { ... }
-stvn
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Using caller to determine the namespace of an anonymous subroutine
by rrwo (Friar) on Feb 26, 2006 at 12:08 UTC |
In Section
Seekers of Perl Wisdom