http://www.perlmonks.org?node_id=913654


in reply to Re^2: constants wont optimize
in thread constants wont optimize

The fix is to throw another BEGIN around the part that sets the constant. I would like to know why it works.

eval is a runtime operation. Sub declaration is a compile time operation. BEGIN does nothing to change that unless you use a BEGIN to perform the runtime eval before the compile time declaration occurs.

All of the operations within a single BEGIN block occur, with respect to each other, in the order they would occur if not for the BEGIN block.