in reply to Getting the size of the call stack (efficiently)
In that case it's a simple matter of incrementing a depth counter on entry and decrementing it just before the return, e.g.
sub gettag { my $self = shift; ($self -> { THIS }{ DEPTH } ||= 0)++; my $tagref = { SUBTAG => [] }; # ... while ( !/<\// ) { push @{$tagref -> { SUBTAG }}, $self -> gettag(); # recursive call } # ... $self -> { THIS }{ DEPTH }--; return $tagref; }
-M
Free your mind
|
|---|