Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Syntax checking without BEGIN blocks

by duff (Parson)
on Apr 27, 2006 at 18:47 UTC ( [id://546085]=note: print w/replies, xml ) Need Help??


in reply to Syntax checking without BEGIN blocks

AFAIK, you can't. The BEGIN subs need to execute as they have the potential to warp the syntax.

  • Comment on Re: Syntax checking without BEGIN blocks

Replies are listed 'Best First'.
Re^2: Syntax checking without BEGIN blocks
by Roy Johnson (Monsignor) on May 01, 2006 at 22:56 UTC
    Seems (to my unfamiliar-with-internals eyes) like it wouldn't be too much of a stretch to have a check option for each phase, so you could syntax-check only the BEGIN phase, for example. I don't even know in what order BEGIN, CHECK, and INIT get run, but each setting would only run "up to" whatever phase you're interested in.

    Would someone who has a better understanding comment on whether that's doable?

    Update: Looks like people know enough to downvote, but not enough to explain. That's never happened before.


    Caution: Contents may have been coded under pressure.

      I think the down votes are because a) syntax checking only through BEGIN, CHECK, INIT doesn't solve the OP's problem and b) because you said you don't know what order BEGIN, etc run in when it's easily discoverable from the docs (never admit weakness ;-).

      Though, in any case your post does present a potential "solution". The OP could modifiy the modules such that any initialization code is in an INIT block rather than free of subroutine shackles and so executed at module use-time. Of course, this is assuming that the code really isn't warping the syntax of the language to its own nefarious desires and really isn't setting up structures needed by future BEGIN-time processes.

      In some sense, perhaps "free" code in modules should automatically be placed in INIT blocks and the module author, if they really need BEGIN-time processing, should be required to say BEGIN { ... }. I'd wager that that's what many people mean with "free" code anyway.

        doesn't solve the OP's problem
        I think it does. He wants to syntax-check code before examining it for security issues. He'd do that for each phase. It's not an all-at-once syntax check, but it does allow syntax-check-before-running.

        The reason I don't know the order of processing of special blocks other than BEGIN is that I have no reason to know. I don't use them. Someone who thinks I should look up something I don't use has a serious proctological issue.


        Caution: Contents may have been coded under pressure.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://546085]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-18 09:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found