Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: Syntax checking without BEGIN blocks

by duff (Parson)
on May 02, 2006 at 15:30 UTC ( [id://546927]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Syntax checking without BEGIN blocks
in thread Syntax checking without BEGIN blocks

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.

Replies are listed 'Best First'.
Re^4: Syntax checking without BEGIN blocks
by Roy Johnson (Monsignor) on May 02, 2006 at 16:09 UTC
    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.

      Perl already "syntax checks" things before running them. Compilation is a syntax check. It compiles something first. If it succeeded then it might be run. If it's a BEGIN block then it is run as soon as it has finished being compiled. If you didn't care about any code past the BEGIN block then you could opt to exit before compiling any more code. If you're going to compile more code then it is mandatory to run the BEGIN block so that any subroutine declarations, prototypes, imported functions, or overloaded things are available.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

      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.

      I don't :-) They want to check everything - note their use case:

      I don't want to start messing with the codebase just to check the debug statement I've added. How do I make perl just check the syntax, and do nothing else?

      and that isn't possible in the Perl world.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-03-28 22:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found