Alexander Ivanov
Alexander Ivanov

Reputation: 11

Sublime syntax highlighting perl qw, qq, q not working fully

From 1 week i use sublime. And i'm very pleased. But i have little problem. I write in perl with sublime.

Here is the problem:

enter image description here

Sublime did not recognize that 'some string is quoted and $test_scalar and everything after it like it is string. When i type it like that:

enter image description here There is no problem.

I tried with the Perl.tmLanguage file, but i did not understand it.

Can someone help me please?

Upvotes: 1

Views: 1716

Answers (4)

David W.
David W.

Reputation: 107060

Perl is one of the few programming languages that use this type of construct for quoting strings, and many program editors simply don't get it.

Imagine you're writing a syntax highlighter, and you have to understand all of these are the same:

my $string = "this is my string";
my $string = qq(This is my string);
my $string = qq/This is my string/;
my $string = qq@This is my string@;
my $string = qq
    (This is my string);

Your syntax highlighter would have to understand that q, qq, and qx are quoting options, and that the character following them (after possible white space) is the character that's doing the quoting. Oh, and also that if the character is a (, a {, or a [, the closing quote is a ), }, or a ]. And, that this can be on more than one line. And, you really only need this for Perl.

I know that VIM can handle the qq quoting issue, but many other program editors I have tried failed. Even Stackoverflow's syntax highlighter (Google's prettify) fails.

Try Notepad++ or Textpad if you're on Windows. Or, try Eclipse with the EPIC editor. I believe that one also works.

Upvotes: 3

Giuliani Sanches
Giuliani Sanches

Reputation: 672

cperl-mode.el for Emacs does the job:

Emacs screenshot

Maybe you can take a look at it's source and try to use the same rules in Sublime or at last point this to the plugin author.

Upvotes: 0

frezik
frezik

Reputation: 2316

Because Perl5 can't be statically parsed, editors have to make guesses about syntax. Could they do a better job in this case? Probably, but do keep in mind that it's impossible to do this perfectly.

In any case, your best bet is to get in touch with the author of the Perl syntax highlighting plugin for your editor.

Upvotes: 1

edem
edem

Reputation: 3272

As you said there is no problem and no syntax error. It is normal behavior either for sublime or vim editor. When you go on write qq operator on next line then highlighting string doesn't works on either editors.

Upvotes: 0

Related Questions