Today at my current client, there was some disagreement over the scoring of job candidates’ FizzBin solutions in the code test portion of the interview. They are allowed to use whatever language they choose but almost everyone does the same thing. Grayson Koonce has a good explanation of the problem with his evolving solution in Go. I decided to do the exercise myself but with extra constraints. I wouldn’t use any conditionals.
Author: brian
AppVeyor combined Linux and Windows Perl module testing
AppVeyor is starting to support Ubuntu builds so I’m playing with some configurations for that by adjusting the pure Windows config I wrote about earlier. Continue reading “AppVeyor combined Linux and Windows Perl module testing”
List comprehensions in Perl (almost)
[I wrote this about two years ago and waited for some inspiration that would make it a little better. That inspiration never showed up. In the new year I’m cleaning out all the draft articles though.]
I went off to see what list comprehensions are all about. Lately I’ve run across several bits of Python I’ve wanted to use. I don’t mind Python so much but I’m certainly rusty; I spend some time on StackOverflow where I run into the term “list comprehension” quite a bit. They sure like whatever that is so I went off to investigate. Someone might want one of those in Perl, hence the click-baity title of this post (a better one might be “12 Ways to…”). Continue reading “List comprehensions in Perl (almost)”
Skipping automated coverage testing for v5.8 on Travis
Previously I had a kludge to allow coverage testing on v5.8 through Travis CI. I used cpanm to install exactly Devel::Cover 1.23 because it supported v5.8. The problem now is that it doesn’t support v5.26 and my automated testing fails. Continue reading “Skipping automated coverage testing for v5.8 on Travis”
Automated Testing on Windows with AppVeyor
You can test Perl on Windows with continuous integration through AppVeyor. I previously showed an example of with Travis CI but that was limited to Linux. You can easily set up an account through GitHub (or other means), select projects to test, and let it do its work. Continue reading “Automated Testing on Windows with AppVeyor”
Using an older version of Devel::Cover to test v5.8
I’ve had a problem with automated coverage testing and v5.8 (the oldest Perl that I support). Devel::Cover made some changes after 1.23 so that it doesn’t guarantee support for v5.8 and earlier. It might work but you’re lucky if it is. Continue reading “Using an older version of Devel::Cover to test v5.8”
Automated testing with Travis CI
Intermediate Perl shows the basics of Perl testing. We show you how to write test programs and how to run those from the command line. That’s the language-specific stuff and within the scope of the book. You can take it further though. You can set up your code in a “continuous integration” system that runs the tests whenever you commit change (most of these trigger on a source control commit). You commit your code and grab some more coffee while your tests trigger themselves. Martin Fowler has some interesting thoughts on CI and wikipedia has a comparison matrix of CI services. Continue reading “Automated testing with Travis CI”
Trying to divide the smallest hexadecimal number
You can run into problems relying on the averages of floating point numbers. This is something I think about often after reading Sinan Ünür’s How you average numbers matters. I thought about it again when I read Honza Brabec’s Mean of two floating point numbers can be dangerous. Despite the hyperbole of “can be dangerous” (see “Considered Harmful” Essays Considered Harmful), it certainly can do something that you don’t intend. Continue reading “Trying to divide the smallest hexadecimal number”
Using Inline::C to look at a number’s double representation
Since Perl v5.22 added hexadecimal floating-point numbers, I investigated how floating point numbers are actually represented. These are specified in IEEE 754 and are something you’ve probably taken for granted. I can use Inline::C to play with these. Continue reading “Using Inline::C to look at a number’s double representation”
Pre-compiled patterns retain their settings if they are interpolated
The qr//
operator precompiles a regular expression and returns a reference to that compiled pattern. You can use that reference with the binding operator to perform a match, interpolate the reference into the match or substitution operators, or combine the reference with other references or literal patterns to make a larger pattern. We cover this in Chapter 9, “Regular Expression References”, but don’t emphasize what happens with regex flags when you combine patterns. Continue reading “Pre-compiled patterns retain their settings if they are interpolated”