in reply to Auditing BEGIN blocks?

Check out PPI, it's apparently a framework for parsing perl (eek! i haven't reviewed it yet).

I know people always say, don't parse perl, but in this case, it wouldn't be so bad. Since a BEGIN block can only look like sub BEGIN {} or BEGIN{}, i suggest you programatically change the BEGIN block to something like IwannaBEGINevil. Off the top of my head something like s/\bBEGIN\b/IwannaBEGINevil/ will do (no real thought put into the regex).

Then you can audit that sub like you would any other user defined sub (if you can do that).

Oy!


MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
** The Third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
•Re: Re: Auditing BEGIN blocks?
by merlyn (Sage) on Dec 18, 2002 at 20:18 UTC
    Since a BEGIN block can only look like sub BEGIN {} or BEGIN{}
    or use .... And there are many things that look like the two things you gave, and are not BEGIN blocks.

    Yes, it's a difficult problem.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re^2: Auditing BEGIN blocks?
by diotalevi (Canon) on Dec 18, 2002 at 16:55 UTC

    If that is the only way to get there then that just means perl5 isn't powerful enough for what I'm asking it to do. I refuse to parse perl. I'll bet on perl6 ;-)


    Fun Fun Fun in the Fluffy Chair