Better Carpentry through Perl

Timbo on 2003-08-16T07:23:00

I am building a deck that, should global warming completely cover Anchorage with water, will serve as the first wooden aircraft carrier.

Anyway, I had an interesting (and uncommon, at least for programmers) problem -- I needed a way to determine if a support beam was perfectly square to my house. Sure, I could use the old 3-4-5 rule (Pythagorean theorem; triangle with one leg 3, other 4, and hypotenuse 5 is a right triangle)(as if I had to explain that in this forum), but I wanted to use the full length of the beam for the shortest leg to minimize the margin for error.

So, I whipped up a perl script. Maybe I was just looking for an excuse. I used Number::Fraction to accept a rational number, and the script would output the length of the longer leg and hypotenuse, in rational number accuracy up to 128ths. All I had to do was mark the proper distance from where the beam met the house, and move the end of the beam around until the hypotenuse length was right.

When your favorite tool is a perl script...