Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Monday June 23, 2008
02:45 AM

I Didn't Want to See That

[ #36746 ]

One thing I found unsettling was running this over our CPAN install:

ack '^\s*exit\b' lib/perl5/

Admittedly, many of those were false positives, but not all of them were. This puzzles me. Even if it's clearly documented, this is a very dangerous practice. How do I cleanly write code for something which might call exit()? Do I have to remember to override exit() every time? Yuck. What this means is that the module author has taken it upon themselves to deny me control over my use of the module.

That being said, exit() isn't always evil. Just mostly evil. Sometimes you need it, but programmers reach for it more than I would like. Even if you're writing a standalone program, you usually don't need to call exit() because Perl's nice enough to pick up after itself. If you do call exit(), Perl has no choice and I, as the person writing tests, am now forced to deal with that. Yuck.

On another annoying note, I realized that my grepl software doesn't have a means of only searching code (it can search POD, heredocs, quoted strings and comments). How did I manage to overlook that?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I just added a TODO for Perl::Critic to forbid exit() from all files that lack a shebang line. A similar policy exists in the Java FindBugs tool, and I've found that policy useful to increase trust in library code.

    Would anyone like to implement that policy? I think it would be quite easy to do, especially given the Perl::Critic::Utils::is_script() helper method and existing example policies in Perl::Critic::Policy::BuiltinFunctions::*