in reply to Intercepting compile time blocks like BEGIN {}

AFAIK CTBs are evaled, so in theory it should be easily possible to intercept the evaling routine to do this.

eval() isn't used. But something is. Does it really matter what that something is?

well not quite ... from perlmod

It refers to:

$ perl -E'eval "BEGIN { say q{foo} }"' foo $ perl -E'eval "UNITCHECK { say q{foo} }"' foo $ perl -E'eval "CHECK { say q{foo} }"' $ perl -E'eval "INIT { say q{foo} }"' $
But it's not completely true. The problem is that eval would normally be used after the CHECK and INIT blocks have triggered. If you use eval earlier, all four blocks work.
$ perl -E'BEGIN { eval "CHECK { say q{foo} }" }' foo $ perl -E'BEGIN { eval "INIT { say q{foo} }" }' foo

Replies are listed 'Best First'.
Re^2: Intercepting compile time blocks like BEGIN {}
by LanX (Saint) on Aug 10, 2010 at 00:03 UTC
    > eval() isn't used. But something is. Does it really matter what that something is?

    theoretically no, practically yes, because extending an eval mechanism shouldn't be difficult "something" OTOH could mean anything much more complicated.

    Cheers Rolf

      Quite the opposite. eval is an op. It's meant to be called from Perl land. This may subject it to limitations and make it a poor choice. Limiting yourself to a specific implementation (without knowing anything about it) is definitely not better.