Today I got tests done, and I kinda abandoned
Error.pm for exception handling. I switched over to using
Try::Tiny since it looks like there are known issues with Error.pm in more modern frameworks like
Moose. I’m going to try to avoid using ##no critic as much as I can, but I had to use it twice in my
ModExec::Exception class since I wanted to include the sugar functions from
Try::Tiny, and since I want to use
die() in my throws to keep the object intact.
Here’s tonight’s changeset: http://tinyurl.com/nuzvnzt
Next up is the base class,
In re-factoring ModExec, I have started with the exceptions. I’m debating how I used to do them. When I first started I used
Error qw/:try/ and
Error::Simple for exceptions. I still think I will, it looks like it’s still being well-maintained by Shlomi Fish (see here).
I think that the piece I will bite off first is to get some test coverage around my exceptions and add documentation. They’re not much more than what you get with
Error::Simple, but there’s some stuff in there for stack dumps and things like that.
Goals for this first pass are:
- Pass a
`perlcritic -3` for all exception code
- Add POD for all exception code
- Add a test for at least some of the methods (more tests will be added later)
Before and After
Here are some GitHub links:
One of the largest critiques I see about regular expressions is that they lack readability. Well, in Perl 5.10 named capture was added (http://perldoc.perl.org/perlretut.html) which I think adds an awful lot of readability to Perl regular expressions. Continue reading Gist of the Day: Named Capture in Perl Regular Expressions (Briefly)
Parallel processing is all the rage these days, and life has me at a point where I’m needing to use it. I am having to minimize dependencies in the task at hand, so I’m having to forego my usual CPAN modules and use basic system calls. It’s not terribly complicated, but just to refresh myself on the basics I went ahead and whipped up a quick demo that I thought others might find useful. This is a very simple demonstration of how to use
wait(). Continue reading Gist of the Day: Playing with Forks