Quoth perl-diddler tlinx.org (Linda W):
> I realize it may not be easy (possible?) for args
removed (shift'ed) from
> the stack, but is there anyway to show the backtrace
with "available"
> arguments
Like this, you mean?
~% perl -MCarp=croak -le'sub foo { shift; croak
"bar" } foo 1, 2, 3, 4;'
bar at -e line 1
main::foo(1, 2, 3, 4) called at -e line 1
> ... i.e. something that would work providing you
didn't
> remove or alter _ (like my $self=shift;)
Some operations destroy the list of arguments: shift does
not, but
splicing _ and assigning to _ both do.
> ...For those that do alter
> _, well -- those frames could show what's left on the
stack?
Removing elements from _ with splice marks unavailable elements
of _
with 'undef'. Unshifting onto _ seems to leave Perl
confused about how
many elements there were to start with: under some
circumstances it
invents a whole lot of 'undef' arguments that were never
there. But
ordinary uses of _ (shift and C<my ($x, $y) = _;>)
leave Perl quite
able to reproduce the list correctly.
Ben
|