Menu

Avoid BEGIN block being executed during syntax checking

Help
2024-07-17
2024-07-22
  • Gerhard Petrowitsch

    I have a Perl/Tk application that uses a splash screen (this is a "greeting" window that opens, before the actual application window opens). This splash screen relies on a BEGIN block in my main Perl file. Now if EPIC does the syntax checking in this file it always opens the splash screen and then a dialog appears that the Perl interpreter stopped working. This happens any time I edit something in this file, which is quite annoying and actually prevents me from editing this file in any sensible way.
    I'm currently evaluating EPIC as an alternative for Komodo IDE, which has the same problem, but offers an option to not execute BEGIN blocks during syntax checking. If I activate this option, the splash screen doesn't open anymore.
    Now I'm wondering if EPIC also has such an option to avoid BEGIN blocks being executed during syntax checking, or if there's any other way to avoid this - e.g. switch off the syntax checking for this file only.

     
  • Jan Ploski

    Jan Ploski - 2024-07-17

    There is no option to avoid running BEGIN blocks. Running these blocks is generally essential for "syntax checking" (actually: reporting compilation errors) to be accurate. If you wish to avoid running certain parts of code in BEGIN block, perhaps you can work around by defining some environment variable (only at actual execution time of the script) and checking for it in inside of the (always executed) BEGIN block.

     
    • Gerhard Petrowitsch

      Hi Jan, thanks a lot for your reply. This sounds like a possible workaround, but I would rather want to have such a variable defined only when the script is syntax checked, so that not every user of my app has to define the variable on his system. But I guess this is also not possible.

       
      • Jan Ploski

        Jan Ploski - 2024-07-17

        I suppose this could be achieved by using a wrapper script for the Perl interpreter (the "Perl executable" in EPIC Preferences). The wrapper could check the command line arguments (specifically for -c), set the enviornment variable if compilation is detected, and then invoke the real Perl interpreter.

         
        • Gerhard Petrowitsch

          Hi Jan, thanks a lot!

           

Log in to post a comment.