And in November's TPJ, I could read his article about Modulinos. This is such a great idea!
Now that I am compulsive about tests, I'm very disappointed with how I can test scripts. These tests are a pain to write: it's difficult to cover all the tests, I have to create loads of data and configuration files to check for each case, I do not get test coverage, etc. Test::Cmd is a great tool (except that I can't have two instances of a Test::Cmd at the same time) but, as bdfoy notes, when testing scripts, you only test the whole process. Does that input produce the expected output? How many files appeared and weren't removed? And so on.
Most of the time, a script is a set of individual actions combined according to the command-line options. Sure, but I don't want to write a whole module and install it in @INC, just to encapsulate those individual actions.
Well, now I can. I just write the module inside the script file, add the magic one-liner** given by brian, and write tests scripts!
The only drawback in my opinion is that, if you want to use the "module", you'll have to name your script foo.pm. If it's only for scripts, I guess you can simply require "foo" in the test suite. And Devel::Cover works as expected!
I think I'll use^Wrequire^Wuse this technique for my future production scripts.
(*) Except for the fact that TPJ is online only... Did you also notice that, contrary to almost every magazine, a particular month's issue is available at the end of the month? I suppose they were late at some point, and never catched up.
(**) You noticed I did not write the one-liner here. It's on purpose. Either 1) brian will write it somewhere for all to see, or 2) you'll subscribe to TPJ. Or both.