Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

perl script checker

by edwardt_tril (Sexton)
on Dec 12, 2005 at 20:04 UTC ( #516133=perlquestion: print w/ replies, xml ) Need Help??
edwardt_tril has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Is there any tools that will check bad programming styles in perl programs?
Finding issues like: some scalars are names as var1 but later
on someone uses as Var1? forgetting to close file handles etc?
I need some like what PClint does with C, C++ program. There is a verison of PCLint
for perl, but it is not very good. Thanks

Comment on perl script checker
Re: perl script checker
by GrandFather (Cardinal) on Dec 12, 2005 at 20:11 UTC

    use strict; use warnings; are your best friends for that sort of thing.

    After that making sure that you use good names for things (var1 is a bad name BTW :) and a clear and consistent indentation style helps a lot.

    Where there is something that will do work for you, use it. That is, use modules, they save reinventing wheels and are likely to have been fairly well debugged - especially if they are popular.


    DWIM is Perl's answer to Gödel
      those code are written by a group other people. so I need to do some analysis and
      it is very hard for me to go thru those lines one by one.
      I have do the use strict and use warnings and found somthing, and just wonder if
      there is anything more/suggestion that people have used???
      thanks
Re: perl script checker
by trammell (Priest) on Dec 12, 2005 at 20:24 UTC
      Perl::Critic is very, very useful if you want to enforce coding standards, or want to start refactoring some "bad" coding practices out of a project.

      That said, it's really only going to catch syntactic and stylistic problems, though. It won't help you find forgotten filehandles, silly program logic, terrible variable names, or other problems inherent in bad legacy code.

Re: perl script checker
by diotalevi (Canon) on Dec 12, 2005 at 20:41 UTC

    See also B::Lint. I'll be giving a short presentation at Minneapolis.pm on Wed Dec 14 2005 about extending B::Lint to cover new warnings.

Re: perl script checker
by Fletch (Chancellor) on Dec 12, 2005 at 21:15 UTC

    Not strict-ly a syntax checker (HAH! I kill me!</ALF>) but perltidy can help get a hairy codebase into a more readable form.

Re: perl script checker
by planetscape (Canon) on Dec 13, 2005 at 10:21 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://516133]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-09-02 22:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (32 votes), past polls