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:
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'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} }"' $
$ 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 | |
by ikegami (Patriarch) on Aug 10, 2010 at 01:06 UTC |