News for hackers. Stuff that matters.
Re:Perl::Critic - Automatically review your code by npsimons on Saturday June 29, 2013 @10:06PM (#5964435)
Re:Perl::Critic - Automatically review your code by lazyjones on Sunday June 30, 2013 @05:54AM (#5965265)
This is essential for Perl programming, along with perl -MO=Lint -c <file>. The downside is that it is slow and takes away the fast turnaround times you're used from scripting languages, checking every file after editing (as you should) takes longer than compiling a Go program ...
Re:Perl::Critic - Automatically review your code by npsimons on Sunday June 30, 2013 @12:38PM (#5966290)
I've been using "perl -tTW" along with "use strict; use warnings; use sigtrap;" before I found out about Perl::Critic, which works nicely with flymake (http://www.gnu.org/software/emacs/manual/html_node/emacs/Fly...). None of it has seemed to slow me down too much.

The thing about these tools (along with other checkers, warnings, errors, etc), for me at least, is they tend to be corrective. I learn not to keep making the same mistakes, if for no other reason that to avoid the "pain". This is just icing on top of the fact that these tools can be automated, especially to prevent code from being checked in or merged when it violates these checking systems.

Re:Perl::Critic - Automatically review your code by hardwaresofton on Saturday June 29, 2013 @08:51PM (#5964285)
You might have an error with syntax highlighter on your page, it's making a dialog box telling me it doesn't have a brush for perl
Re:Perl::Critic - Automatically review your code by ratsbane on Saturday June 29, 2013 @08:23PM (#5964210)
For Debian/Ubuntu: sudo apt-get install libtest-perl-critic-perl
Re:Perl::Critic - Automatically review your code by nnutter on Saturday June 29, 2013 @09:37PM (#5964378)
libperl-critic-perl is the core Perl Critic. libtest-perl-critic-perl is for using Perl Critic in tests.
Re:Perl::Critic - Automatically review your code by systems on Saturday June 29, 2013 @08:36PM (#5964250)
i dont see how the debian maintainers can keep up with cpan, just use cpan for perl

generally speaking, i find the centralized packaging system flawed ... because on the long term its unsustainable

cpan is decentralized by the way, because module makers package their modules themselves for cpan

Re:Perl::Critic - Automatically review your code by ratsbane on Saturday June 29, 2013 @08:45PM (#5964274)
I go back and forth on this. Aptitude seems more reliable in general than cpan, at least in the sense that cpan installations fail more frequently than apt.

Also I assume that cpan packages reflected through apt will be updated with apt-get update, while cpan has no similar update-all mechanism (AFAIK).

One advantage of using cpan is that if you're developing on a Mac and deploying on a Debian distro you can use the same commands on both systems to pull in the packages you need.

Re:Perl::Critic - Automatically review your code by systems on Saturday June 29, 2013 @09:09PM (#5964314)
when dealing with cpan, i think you should separate between the repository itself, which is surely more up to date than debian or ubuntu repos (because this is where debian or ubuntu pull from anyway)

and the command line interface, you have cpan, cpanp (cpan plus) and cpanm (cpan minus)

some cpan interfaces work better than others

Re:Perl::Critic - Automatically review your code by Moto7451 on Sunday June 30, 2013 @03:53AM (#5965062)
To update all packages use:

cpan upgrade /(.*)/

Re:Perl::Critic - Automatically review your code by gnosis on Sunday June 30, 2013 @11:09AM (#5966009)
That doesn't seem to work for me.

First, typing that in the shell gives me an error:

  zsh: no matches found: /(.*)/
So, I tried typing:

  cpan upgrade '/(.*)/'
Which at least kept my shell from trying to expand the last argument, but cpan complained:

  Warning: Cannot install upgrade, don't know what it is.
  Try the command

    i /upgrade/

  to find objects with matching identifiers.
  Sorry, install with a regular expression is only supported when unambiguous.
  Rejecting argument '/(.*)/'
So, instead at the shell I just typed:

  cpan
Then, at the cpan[1]> prompt, I typed:

  upgrade
That seemed to work.
Re:Perl::Critic - Automatically review your code by Moto7451 on Sunday June 30, 2013 @12:25PM (#5966266)
Sorry meant the CPAN shell. Should have reproduced the prompt better. Also it does appear that the regex isn't required any longer. That's certainly nice.
Re:Perl::Critic - Automatically review your code by nnutter on Saturday June 29, 2013 @09:38PM (#5964381)
There are trade-offs. There is no perfect solution.
Re:Perl::Critic - Automatically review your code by csirac2 on Sunday June 30, 2013 @03:12AM (#5964992)
That's why I just use cpan2deb. There's a few modules that won't package properly with it, I should file some bugs.

I also use cpanm when I have a need to be separate from vendor, but generally in the worst-case admins prefer to only maintain one set of perl/cpan rather than two.

Re:Perl::Critic - Automatically review your code by gnosis on Saturday June 29, 2013 @09:01PM (#5964301)
"i find the centralized packaging system flawed ... because on the long term its unsustainable"

Could you elaborate on why you think this?

Re:Perl::Critic - Automatically review your code by systems on Saturday June 29, 2013 @09:23PM (#5964351)
i hope engaging in this clearly off topic, wont offend others

linux and foss rely on volunteer effort, therefore efficiency matters a lot, inefficient system will loose volunteers and momentum, i think its surprising the system lasted for so long , but then i believe the number of surviving distros is in decline and even less so the number of package management system

anyway, maybe my usage of the word centralized and decentralized term is wrong

cpan can be viewed as centralized, it is a single storage space for all modules

i just believe that is too much waste, in having to repackage each application to different systems, there must be a better way, where the effort will be more efficient and require less resources

maybe the opposite of what i said is true, maybe we need to centralize over one package system to reduce the effort, or in other, maybe we need we centralized over a single system and repo, to be able to decentralize the effort

Re:Perl::Critic - Automatically review your code by berntb on Sunday June 30, 2013 @04:16AM (#5965094)
I thought most people would have as main reason to not mix their own stuff with the system Perl?!

And you want multiple Perls installed, anyway. Backward compatibility is a target in the Perl world, but stay safe... ("This is the versions at the job servers. This is what I do my hobbies with. Also, I need to keep a 5.8.8 Perl, to make certain so X works with that golden oldie.")

Re:Perl::Critic - Automatically review your code by ancarda on Saturday June 29, 2013 @09:07PM (#5964312)
Please tell me there is something like this for PHP or JS?
Re:Perl::Critic - Automatically review your code by dharbin on Saturday June 29, 2013 @09:36PM (#5964376)
JSHint[1] seems to be the most popular JS linter, although I believe Perl::Critic to be the more powerful of the two tools. I've always appreciated how Perl::Critic allows you to write your own rules, and I wish JSHint was so customizable because I have coding standards I'd like to automate that don't exist in JSHint's options.

1: http://jshint.com/

Re:Perl::Critic - Automatically review your code by lazyjones on Sunday June 30, 2013 @07:00AM (#5965354)
> I believe Perl::Critic to be the more powerful of the two tools.

It is quite limited by Perl's quirky syntax, unfortunately ("only Perl can parse Perl"). Last time I checked, it would miss e.g. all warnings for anonymous subs:

  # triggers "Subroutine "foo" does not end with "return" at line 5, column 1.  See page 197 of PBP.  (Severity: 4)"
  sub foo {
      my $s=shift;
  }

  # triggers no warnings 
  my $x = sub {
      my $s=shift;
  }
This is a bug/limitation in PPI (which otherwise does a great job with the mess that is Perl syntax) ... I'd assume the various JS analysers can do a more thorough job.
Re:Perl::Critic - Automatically review your code by rwalker on Saturday June 29, 2013 @09:15PM (#5964334)
For JavaScript, one option is the Closure Linter

https://developers.google.com/closure/utilities/

(disclaimer: I helped write this when I was working there)

Re:Perl::Critic - Automatically review your code by shuzchen on Sunday June 30, 2013 @04:29AM (#5965121)
Re:Perl::Critic - Automatically review your code by zzzcpan on Saturday June 29, 2013 @09:13PM (#5964326)
There is, google for something like php lint or js lint.
Re:Perl::Critic - Automatically review your code by McGlockenshire on Sunday June 30, 2013 @03:05AM (#5964981)
For PHP, there's PHP_CodeSniffer, though it's not quite the same thing.
Re:Perl::Critic - Automatically review your code by Snowda on Saturday June 29, 2013 @10:41PM (#5964496)
Anybody know a similar piece of software for C or Python?
Re:Perl::Critic - Automatically review your code by mcarreno on Sunday June 30, 2013 @12:17AM (#5964687)
For C, C++ or Objective-C check out the Clang Static Analyzer.

http://clang-analyzer.llvm.org/

Re:Perl::Critic - Automatically review your code by rwalker on Saturday June 29, 2013 @11:11PM (#5964549)
For python: pylint is nice

http://www.logilab.org/857

Re:Perl::Critic - Automatically review your code by dj-wonk on Sunday June 30, 2013 @01:38AM (#5964798)
Q: What's the difference between writing Perl and taking a severe beating? A: Nothing. The wonder of Perl is that it helps you get the latter without needing any external assistance.
Re:Perl::Critic - Automatically review your code by dj-wonk on Sunday June 30, 2013 @08:52PM (#5968027)
You downvoters are so uptight! Are attempts are humor against HN guidelines? Surely (or maybe not!) you can appreciate a good joke? Unless it hit too close to home, pun intended? (Disclaimer: I do not advocate taking a severe beating, Perl-inflicted or otherwise.)
Re:Perl::Critic - Automatically review your code by maxerickson on Sunday June 30, 2013 @09:20PM (#5968102)
I didn't vote on any of your comments here. Humor doesn't go all that well here, my take on that is that it is of course subjective, and a whole lot of it is quite a bit less original than maybe the commenter thinks (which turns it into a sort of noise).
Re:Perl::Critic - Automatically review your code by dj-wonk on Sunday June 30, 2013 @01:26AM (#5964779)
What's the difference between asking how to improve Perl code and Satan going to confession? The latter might have some chance of redemption.
Re:Perl::Critic - Automatically review your code by dj-wonk on Sunday June 30, 2013 @08:58PM (#5968039)
Q: What's the difference between "better" and "worse" Perl code? A: http://www.matthewsdiehl.com/wp-content/uploads/2009/01/rock...

(I submit these slides in support of the previous rhetorical question: http://www.oualline.com/talks/perl.pdf)