develooper Front page | perl.perl5.porters | Postings from March 2000

stack backtrace confusion

Thread Next
From:
Tom Christiansen
Date:
March 22, 2000 10:07
Subject:
stack backtrace confusion
Message ID:
24925.953748448@chthon
I don't know whether it's cluck or me or both, but this output seems weird
at best.

    use Carp qw/cluck/;

    backtrace();

    END { backtrace() }
    END { cluck "And now we're done" }
    BEGIN { cluck "Let's start it all rolling" }
    END { cluck "I was done first!" }


    sub backtrace  {
	print "DUMP BACKTRACE:\n";
	my $i = 0;
	while (my($pack, $file, $line, $sub) = caller($i++)) {
	    print "\tCALLED: $pack $file $line $sub\n";
	}
    }

Makes:

    Let's start it all rolling at /tmp/x line 7
	    main::BEGIN() called at /tmp/x line 7
	    require 0 called at /tmp/x line 7
    DUMP BACKTRACE:
	    CALLED: main /tmp/x 3 main::backtrace
    I was done first! at /tmp/x line 8
	    main::END() called at /tmp/x line 0
	    require 0 called at /tmp/x line 0
    And now we're done at /tmp/x line 6
	    main::END() called at /tmp/x line 0
	    require 0 called at /tmp/x line 0
    DUMP BACKTRACE:
	    CALLED: main /tmp/x 5 main::backtrace
	    CALLED: main /tmp/x 0 main::END
	    CALLED: main /tmp/x 0 (eval)

--tom

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About