Subject: | put a note about aliases at DB::args |
because of @DB::args refers @_ which holds aliases
we can not store results in array ref: $x = called_args( 2 );
When user's script exists sub at level 2 trying to access $x->[ 0 ] will case die with message you are trying to access freed variable.
http://perldoc.perl.org/functions/caller.html
Be aware that setting @DB::args is best effort, intended for debugging or generating backtraces, and should not be relied upon. In particular, as @_ contains aliases to the caller's arguments, Perl does not take a copy of @_ , so @DB::args will contain modifications the subroutine makes to @_ or its contents, not the original values at call time. @DB::args , like @_ , does not hold explicit references to its elements, so under certain cases its elements may have become freed and reallocated for other variables or temporary values. Finally, a side effect of the current implementation is that the effects of shift @_ can normally be undone (but not pop @_ or other splicing, and not if a reference to @_ has been taken, and subject to the caveat about reallocated elements), so @DB::args is actually a hybrid of the current state and initial state of @_ . Buyer beware.