Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^5: Backdating strict

by jcb (Parson)
on Nov 19, 2020 at 00:21 UTC ( [id://11123803]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Backdating strict
in thread Backdating strict

The syntax highlighting in Emacs' cperl-mode is extensive and tends to catch most of my syntax errors when I notice that the code did not highlight as expected.

This is particularly useful for catching sigil and subscript typos — CPerl mode highlights direct array and hash lookups accordingly, so if I miss the shift key and type $foo[bar] instead of $foo{bar}, the syntax highlighting will indicate my mistake almost instantly.

Replies are listed 'Best First'.
Re^6: Backdating strict
by LanX (Saint) on Nov 19, 2020 at 00:28 UTC
    I just wanted to return to the topic on how an IDE can help refactoring to strict.

    I agree that cperl's syntax highlighting is among the best.

    But it can't help catching typos in variable-names or scoping problems. That's where flymake et al. comes very handy.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      I have never refactored code to use strict; because all of my code has been written under strict (command-line one-liners excepted), but when I have had typos in variable names, I have always had great success by simply running the script at a terminal and letting perl point out the errors.

      Since this is presumably functioning code, we can expect that there will be no variable-name typos. The simplest option for moving to strict would be to add use strict; and then use vars at top-level, listing the variables already used until all are declared. Narrowing the scopes to lexicals can then be done incrementally, using grep or Emacs' M-x occur to identify where each name is mentioned in the code and understanding of the program to determine where values can be reduced to narrower scopes.

        > I have always had great success by simply running the script at a terminal and letting perl point out the errors.

        You never tried flymake-mode, right? :)

        And why do you run it in a terminal instead of a compilation buffer?

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11123803]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found