No syntax highlighting in Perl modules (*.pm)

Help
Evgeny
2012-07-26
2013-05-20
  • Evgeny
    Evgeny
    2012-07-26

    Hello!
    Everything works great for Perl files (*.pl), but there's no syntax highlighting in the modules. The files are in the same project and are opened by the EPIC Perl Editor by default. The advice from here, but only once. Now I just cannot get back the highlighting whatever I do.
    I also had "Colorer" plugin installed, but uninstalled it shortly after - maybe it could cause the problem.
    Eclipse version: 3.7.1
    EPIC verson: 0.5.46
    Any help will be very appreciated!

     
  • Jan Ploski
    Jan Ploski
    2012-07-26

    Maybe this will help: in Preferences go to File Associations and check *.pm: there should be "Epic Perl Editor (default) locked by Perl Source File content type" - if it's not marked as default, click the Default button. At least this is how it appears in EPIC 'testing' (0.6.x).

     
  • Evgeny
    Evgeny
    2012-07-26

    jploski, thank you for the quick response.
    I went to Window->Preferences->General->Editors->File Associations and that line you pointed out was already there. There also was "Text Editor locked by 'Perl Source File' content type", but it wasn't marked as default.
    I even deleted and then added again the *.pm file type, but, unfortunately, it didn't help.

     
  • Jan Ploski
    Jan Ploski
    2012-07-26

    If you create a new module file, does it open with the wrong editor? It could be that the wrong association is stored for some files only. Another thing to check is "Content Types" in Preferences - there should be a "Perl Source File" with "*.pl", "*.pm" and "*.t" listed below as File associations. Finally, you may consider upgrading to EPIC 0.6.x (testing).

     
  • Evgeny
    Evgeny
    2012-07-27

    "Content Types" are also OK, just as you say they should be.
    When I added a new module, it was opened with the right editor (EPIC Perl Editor), but I began typing and the errors were shown. So, I copied all my code from the old module and pasted it into the new one… And syntax check disappeared. I started deleting text line by line from the beginning of the file and found out that the culprit code lines were:

    BEGIN {
      push @INC, catdir( dirname( $INC{ 'ThisModule.pm' } ), qw( .. OtherModulesFolder ) );
    }
    

    This block spoils syntax check in this state, but doesn't spoil it if I remove BEGIN {} or leave nothing between the curly brackets. Any ideas?

     
  • Jan Ploski
    Jan Ploski
    2012-07-27

    Sure, BEGIN blocks are executed (not just parsed) by the compiler (perl -c) and syntax checking is done by the compiler as well. If you have something in a BEGIN block that causes the compiler to abort prematurely, it won't report syntax errors to  EPIC. There is nothing that EPIC can do about it.

     
  • Evgeny
    Evgeny
    2012-07-30

    It seems that Perl couldn't locate current module name in `@INC` - that's why `perl -c` was interrupted by error inside of the `BEGIN` block. So, you were absolutely right, jploski. Thank you very much for your help.
    Possible solutions to this problem can be found on StackOverflow.