thens has asked for the wisdom of the Perl Monks concerning the following question:

This is not really a perl question. More related to emacs. I have this problem where emacs does not higlight properly after encountering the following scenarios.
  1.  next if /^#/;
  2.  $str = '^\d{8}$' # Match exactly 8 digits.

Any code after this is not indented/highlighted properly.

A workaround for case # 1 is  next if  /^\#/;

Can you suggest any setting in cperl-mode or a workaround in perl to make emacs highlight properly anything after case #2

-T

Replies are listed 'Best First'.
Re: syntax highlighting in emacs
by maa (Pilgrim) on Dec 29, 2003 at 14:37 UTC

    Hi,
    does this happen all the time?

    Your example #2 has a missing semi-colon before the comment... dunno if that's all you're missing tho!

Re: syntax highlighting in emacs
by mpeppler (Vicar) on Dec 29, 2003 at 18:02 UTC
    Workaround for #2 is:
    $str = '^\d{8}$' # ' Match exactly 8 digits.
    i.e. include a single quote in a comment on the same line. It's not perfect, but it works for me.

    Michael

      Thanks. It Works !!

      If it is of any help my xemacs version is 21.1.

      -T

Re: syntax highlighting in emacs
by matthewb (Curate) on Dec 30, 2003 at 02:10 UTC
    Can you suggest any setting in cperl-mode or a workaround in perl to make emacs highlight properly anything after case #2

    I checked out the latest emacs sources from Savannah recently (calls itself 21.3.50.3) and was delighted to note that the version of cperl-mode that was included (v. 5) fixed the formatting problems you describe. I had no problem using this cperl-mode with older versions of emacs; YMMV.

    Previous versions of cperl-mode suffered from occasional hiccups, many of which may be worked-around by inserting a comment after the offending line.

    MB
Re: syntax highlighting in emacs
by bschmer (Friar) on Dec 29, 2003 at 14:38 UTC
    Hmm. Case #2 works fine in the version of emacs that I am running (21.2.1). Where does the highliting break down?