develooper Front page | perl.perl5.porters | Postings from January 2012

BEGIN and END are added to the stash/symbol table

Thread Next
From:
demerphq
Date:
January 12, 2012 05:25
Subject:
BEGIN and END are added to the stash/symbol table
Message ID:
CANgJU+WrU4jfyBCyRFYYUPm7nVN25dTrH6bTzemQ+Bj=8iJ7_g@mail.gmail.com
Does anyone know if this is intentional?

$ perl -le'{package Foo; sub bar {} BEGIN{print "this is the
beginning"} END{ print "this is the end" } } print "symbol: $_" for
keys %Foo::;'
this is the beginning
symbol: bar
symbol: BEGIN
symbol: END
this is the end

I would not have expected BEGIN and END (nor any of the other
"special" subs) to end up in the namespace they are used, but they do.

Cheers,
yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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