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

I copied some code from another Perlmonks article and pasted it into my script. In emacs in CPerl mode, the syntax highlighting goes insane midway through the line marked "WHAT IS HAPPENING...?" I've played with parens, retyped it manually, etc. to no avail. I can't see the problem!
while (1) { $! = undef; # no error, yet if ($select->can_read(10)) { $rc = sysread($sock, $buffer, 64*1024, length($buffer)); next if $rc; # continue if not error and not "e +of" last if defined($rc); # exit if "eof" } else { $rc = ( $! ? undef : 1 ); # WHAT IS HAPPENING HERE????? last if $rc; } + + redo if $! == EAGAIN ; # Not really expected, even with no +n-blocking redo if $! == EINTR ; # Signals ! + + + last ; # exit on "hard" error }
Well, gosh. Those long lines aren't REALLY there. I just can't seem to make them go away in this browser edit window. Maybe something with Chrome?

Replies are listed 'Best First'.
Re: Emacs CPerl mode - confused?
by ibm1620 (Hermit) on Feb 24, 2014 at 23:37 UTC
    Interestingly, putting double quotes around $! seemed to satisfy CPerl.
    $rc = ( "$!" ? undef : 1 );
      C-h v cperl-version ?

      update

      I can confirm that indentation also gets confused and your quoting-workaround solves this.

      my cperl-version "6.2" should be quite new, though Ilya's page seems to be down...

      I don't really trust the rumors that J. Rockway took over maintainership, without seeing such an announcement from Ilya.

      Cheers Rolf

      ( addicted to the Perl Programming Language)

        This is something that happens with some built-in perl variables and also when using regexes sometimes. With the built-in variables I use () around them to make the syntax colouring work out, like this

        $rc = ( ($!) ? undef : 1 );

        I didn't test in this particular case, but that should work better. using "" may alter behaviour (or not), so I'm less keen on using that...

        Highlighting with regexes can be more cumbersome to correct, but that's not the problem you have right now ;)

        --

        ecocode

Re: Emacs CPerl mode - confused?
by Anonymous Monk on Feb 24, 2014 at 23:35 UTC