Stupid state trick

Occasionally I find myself writing a Perl subroutine that uses a module that no other part of the code needs. This subroutine may be called multiple times, or not at all. At some point I wondered if putting some logic around the require statement would be faster than just calling it every time. require() is idempotent, after all. You could do something like $counter++ or require Foo;, but the variable has to live somewhere outside the subroutine. Not neat.

It occurred to me that, given P…

The Case of the Preferred Parent

In which Dupin expounds on inter-generational relationships.

Stupid less (1) trick

Do you get tired of reading a man page, or even
perldoc, for cryin' out loud, and having to deal with the
POSIX regex engine instead of something more powerful and Perl-like? I
know I do. Every time I type /^[[:space:]]+something,
instead of /^\s+something, it just makes me sick. Something
ought to be done about this nonsense.

Well, after saying something like this to myself for the umpty-jillionth
time, I decided to look into it.

Announcing Perl::Critic::Policy::ControlStructures::ProhibitForeachHandle

A couple days ago I uploaded a Perl-Critic policy to find and complain about things like foreach ( <FOO> ) {...}. The problem (or at least potential problem) with this is that it sucks the entire file into memory before performing the first iteration. Which may be what you wanted, but may not be too.

I plan to leave it at a development release for a couple weeks to allow time for comments and so on. You can find it at its CPAN Search page.

Announcing Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter

The subject Perl-Critic policy is an alternate implementation of the core policy Variables::ProhibitUnusedVariables. My implementation attempts to do a more thorough job of finding unused variables.

The details of the policy can be found at Perl-Critic-Policy-Variables-ProhibitUnusedVarsStricter. My purpose here is more to discuss why the policy exists in the form it does.