my @stack; for ( my $depth = 0, my $frame = [ caller $depth ]; scalar( @$frame ); $depth++ ) { push @stack, $frame; }