Menu

Package Variables

Ben Imp
2003-10-15
2003-11-07
  • Ben Imp

    Ben Imp - 2003-10-15

    Good afternoon.

    First of all, very nice work on this latest release of the perl plugin for eclipse.  I am using it at work, and it is a nice alternative to the activestate plugin for .NET ... and quite a bit cheaper :)

    I have noticed one thing, however.  When I am working on a few of my modules, the editor flags all of my package variables as warnings, as they are used only once in that file.  This does make sense if you only consider this one file - but these package constants were defined so that they could be referenced by all my other modules.

    I know this is how the perl interpreter works as well, as whenevere I run perl -cw module.pm on this same file, I get the same warnings.  Currently I have up to around 20 or so of these warnings in a single file, which REALLY drags the editor's speed down - nearly to the point of unusability depending on how many scoped variables I have.   I was just wondering if there could be a way to not take these messages into account, or perhaps somehow get the editor to check the other file for these variables.

    Since the perl executable itself gives these messages, im not certain how feasable dealing with this situation would be - but I just thought I would bring it to attention.

    Thanks again for the plugin, works great.

     
    • Ben Imp

      Ben Imp - 2003-10-15

      I may have actually found a semi-solution to my own problem.

      I researched the perl command line switches and found that if you used the -m(module) flag, the package variable problem is solved - as perl will compile the selected module before it compiles the target script.

      So, for instance, the way it works currently.

      c:> perl -c myscript.pl

      Name "OtherModule::UNKNOWN" used only once: possible typo at OtherModule.pm line 776.
      ... etc
      myscript.pl syntax ok.

      But when I do this:

      c:> perl -mOtherModule myscript.pl

      myscript.pl syntax ok.

      Now im not certain if this would be a feesable way to get rid of the problem I posted above, as it takes a tiny bit longer to run this command than it does to just run the normal compile, and that extra overhead may just end up slowing down the editor anyway - but its an idea.

       
    • Ben Imp

      Ben Imp - 2003-11-07

      Found out this really isnt even a bug at all ...

      It dawned on me at work, as I was reading The Camel the previous night - brushing up on some perl.  In particularly, I reread the section on require vs use, and how require doesnt actually load in the module - just makes sure its available.  So when you tell perl to compile it, obviously the package exists ... but it never loads the variables into memory ... therefore generating all these annoying warnings ...

      Sweet ... EPIC rocks again ... and the Camel proves it will always rock.  And I need to do some refreshing of my random perl knowledge...

       

Log in to post a comment.