All pastes #1356604 Raw Edit

Calldepth

public text v1 · immutable
#1356604 ·published 2009-03-09 16:37 UTC
rendered paste body
a(40);
sub a {
        print calldepth(),$/;
        if ($_[0] > 0) { a($_[0]-1); }
}
sub calldepth {
        my $i = 0;
        while(  @a = caller($i++) ) {

        }
        return $i - 1;
}