Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Syntax checking without BEGIN blocks

by bluto (Curate)
on Apr 28, 2006 at 16:36 UTC ( #546315=note: print w/ replies, xml ) Need Help??


in reply to Syntax checking without BEGIN blocks

I like to syntax check my own code, esp during a development cycle. (This isn't as useful for other people's modules but that's why test suites exist.) As others have mentioned, perl itself is unable to do this in all cases. IMO it is a module writer's responsibility, if at all possible, to allow the module user to check their own code without side effects. For example, it appears that most simple side effects (e.g. unlink) can be "commented" out with the $^C variable like this...

unlink("myfile") unless $^C;

I haven't seen much mention of $^C in the past, so perhaps someone more knowledgable can comment on whether this is always effective.


Comment on Re: Syntax checking without BEGIN blocks
Download Code
Re^2: Syntax checking without BEGIN blocks
by Anonymous Monk on May 01, 2006 at 16:38 UTC
    IMO it is a module writer's responsibility, if at all possible, to allow the module user to check their own code without side effects.

    That assumes no incompetence or malice on the part of the module writer. One of the first tests of competence is to see if the module is will actually pass a syntax check.

    The problem of how to do that safely is really the one I'd like to address.

      If you are worred about incompetance or malice, you better visually inspect the module and the Makefile that comes with it (I certainly do). Syntax checking is great for finding bugs during compiling your own code, but don't confuse it with keeping things safe. In fact the safest code is code that fails a syntax check.

      Syntax checking can't stop someone from writing syntactically correct, non-BEGIN block, destructive code. All they have to do is bury something like system("rm -rf *") in the module somewhere and you will have lots of fun trying to find out why your system doesn't work.

        Syntax checking can't stop someone from writing syntactically correct, non-BEGIN block, destructive code. All they have to do is bury something like system("rm -rf *") in the module somewhere and you will have lots of fun trying to find out why your system doesn't work.

        True. However, if the code doesn't pass a basic syntax check, I don't need to waste my time deciphering it. I know it doesn't run. If it is code that's syntactically correct, something might be using it...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-08-30 20:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls