Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Syntax checking without BEGIN blocks

by TedPride (Priest)
on Apr 27, 2006 at 18:55 UTC ( [id://546088]=note: print w/replies, xml ) Need Help??


in reply to Syntax checking without BEGIN blocks

Just write a Perl script to move the BEGIN blocks to the front, and replace the BEGIN with do and comment markers. Test your code. Then use another Perl script to move the blocks back.
  • Comment on Re: Syntax checking without BEGIN blocks

Replies are listed 'Best First'.
Re^2: Syntax checking without BEGIN blocks
by chromatic (Archbishop) on Apr 27, 2006 at 21:40 UTC

    Why write a separate Perl script? Turn this into a module that sticks a codref in @INC to filter the BEGIN blocks into harmless normal subroutines. Acme::Incorporated shows how.

Re^2: Syntax checking without BEGIN blocks
by Anonymous Monk on Apr 27, 2006 at 21:28 UTC
    Yuck. Isn't there an option to the syntax checker to just, you know, check the syntax without actually running anything? :-(

    Is anyone working on this?

      I think you might have missed the point about begin blocks. In order for perl to check syntax it HAS to run the use statments, because the use statments can change perls syntax. Thinks like subs in the modules included could add behaviour to bare words, especialy subs with prototypes.


      ___________
      Eric Hodges
        I think you might have missed the point about begin blocks. In order for perl to check syntax it HAS to run the use statments, because the use statments can change perls syntax. Thinks like subs in the modules included could add behaviour to bare words, especialy subs with prototypes.

        Sure. It needs to include files that contain code definitions. I get that. But why does it have to run non-defining/including code to do that? Surely there's an important difference between choosing to run a sub definition to define a function and or prototype, and choosing to run everything, including calls to unlink()!

        Are you saying it's impossible to write a proper syntax checker in perl? I really hope that's not true. I just want a checker that can check the program's syntax, without doing anything else. No trying to access databases, no writing to the filesystem, just a simple check to see if the code will run.

        Is that really too much to ask? :-(

          A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-20 05:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found