Stupid Perl Tricks

I’m certainly delving into some depths of Perl I’ve never touched before.

I need to lookup a record in one table using a subclass of DBIx::SearchBuilder::Record, and depending on what it says in the “table_name” column, look up a record in one of several other tables, each one of which has its own subclass of DBIx::SearchBuilder::Record. And after some delving on the internet, I was amazed to find out you could put the class name in a variable when you “new” it. Unfortunately you still need to “eval” the require statement.

my $mainRec =
RTx::FooProject::Record::MainTable->new($cfHandle);
$mainRec->LoadById($main_id);

# Ok, here comes the tricky part. Try to get figure out the class name
# from the table name
my $table_name = $mainRec->table_name;
$table_name =~ s/^dsu/DSU/i;
$table_name = ucfirst($table_name);
$table_name =~ s/_([a-z])/uc($1)/eg;
$table_name =~ s/s$//;

my $subRec;
{
no strict 'refs';
my $fullClass = "RTx::FooProject::Record::$table_name";
eval "require $fullClass";
$subRec = $fullClass->new($cfHandle);
$subRec->LoadByCol("main_id", $mainRec->id);
$self->SubTableRec($subRec);
}

I literally threw my hands in the air in exultation when it worked. And then was rather painfully reminded of my recent shoulder surgery.

Perl and IDEs

From about 1987 to about 4 or 5 years ago, I did all my software development using vi (and later gvim), ctags, and all the Unix command line tools. But towards the end of my time at Kodak, I got the Eclipse religion, at least as far as doing Java. Sure, I dislike having to move my hands away from the keys to move the cursor around all the time, but the code completion, integrated debugging and all that other good stuff won me over. The ability to click on an existing method call and see the javadoc for the method and to hit F3 and be taken to the actual code was a game changer for me. So much better than ctags. But for non-Java, whether shell scripts at work or perl at home, I still relied on gvim and the other command line tools.

But I’m about to start a huge and long term perl project, a large part of which is trying to learn all I can about an existing open source code base. So I wanted to see if an IDE would give me an advantage in terms of moving around the code I’m trying to learn. I installed the EPIC plugin for Eclipse, and also a dedicated perl IDE called “Padre”, and noodled around on both, and so far I’m forced to conclude that neither of them are as useful in perl as Eclipse is in Java. The biggest missing feature seems to be that F3 gets me the wrong function or method declaration most of the time. I don’t know why, possibly the typing system in perl is too weak for the sort of analysis and introspection that Eclipse does in Java.

So I think I’m going to be back to doing gvim and ctags and find and grep and perldoc and all the other fun stuff.

Moving on, moving up…

I was a little bit annoyed at work this week – they had me rush rush rush to finish something, and when I did they didn’t seem to have anything more for me to do. Ok, if I’m honest with myself, this new subproject they put me on has annoyed me because nobody seemed to want to communicate, and so maybe I wasn’t making the effort I should have to go find something to work on when they didn’t give me something. But still, I was mildly annoyed.

And then out of the blue, an on-line friend popped up on Facebook and said “hey, do you know any perl programmers looking for a job?” Well, I’ve done a fair amount of perl coding for my navaid.com site as well as scripts here and there at Global Crossing and Kodak, although I’m not one what you’d call a “perlmonger” or “perl monk”. As a matter of fact, I’ve been seriously telling people on StackOverflow that if I weren’t so proficient in perl already and didn’t have so much working code written in perl, I would seriously be trying to forget everything I knew about it and learning python instead. So I asked him for more details. But he quoted me an hourly rate that was more than double what I’m currently making. I suddenly remembered that I’m a perl God.

The contract involves learning all there is to know about their business process, and all there is to know about an open source project called “Request Tracker” (aka RT), and seeing how much of their business process I can shoe-horn into RT (using its built in customization hooks and APIs) and how much would require custom coding of separate apps that maybe talk to RT for some parts, and doing the customizing of RT and the custom app coding.

In some ways this job looks like enormous fun and quite a growth experience, but “growth experience” also means “opportunity to fail” so I’m also somewhat scared of this. Not only do I have to become proficient in RT and in corners of the perl world that I’ve never touched before (Mason, anybody), but I’ve got to do my own requirements gathering, project plan, and every other aspect. I’ve got nobody else to blame if things don’t go right. But looking at the sunny side, if I do this right, I’ve got a major successful project on my resume and a happy customer to vouch for me for the next thing that comes along. It’s going to be great!

Anyway, long story short, I just turned in my notice at my current job. No more 3.5 hour return drives to Ithaca every week or two. (I just spent over $1000 on flights, hotels and rental car for a week down at their site for the project kick-off one week info dump, though.)

Training on the erg

Because the weather is turning bad, I’ve been turning to the erg to do most of my training on. I’ve been doing a lot of kayaking, trying to build up the distance I could go on it. When I first started using the erg, I was disappointed that I could only seem to go a very short distance on it before my muscles got tired, like 500 metres a few days after I’d managed 4 miles (6.5km) in a kayak. I think a lot of that is due to the fact that in the boat, the wing paddle “kicks out” on its own, assisting you in getting your rear arm up in the air ready for the next stroke, whereas with the erg you have to lift it up yourself. Also in the erg there is some resistance at the rear part of the stroke where in the boat your paddle is fully out of the water and just “following through” with no resistance. (Hey, here’s an idea – why not use an electromagnet instead of a fan for resistance, then you could trigger it to remove the resistance when your paddle stroke hits the part where you’d normally have no resistance?)

Anyway, Dan said not to be discouraged, and if I could only do 500 metres to do 500 metres. So that’s what I did – I did 500 metres the first day, the next day I did 500 metres, rested until my heart rate was down under 100 bpm and did another 200 metres, and so on until I was doing 5 reps of 500 metres. Then I stepped up to 600m, doing 3x600m the first day, 3×600 plus a bit the next, 4×600 the next, and so on.

Two nights ago I did 5x700m. Last night I did my 5x700m but when I hit the end of the last 700, I just hit reset on the computer and did another 700m without stopping. It felt good to do that.

It’s a definite trend that I don’t feel as sore and tired at the end of the third and subsequent reps as I do at the first two. I’m starting to experiment to see if I can do some stretches and the like so the first two don’t feel so bad. Another thing I might try is doing a couple of short reps to warm up, then doing longer ones.

One interesting thing about this is that I’m having more trouble with the shoulder that didn’t get operated on than the one that did. On Friday I’d had a really good work-out, thought that maybe next day I could really step it up (to 1000m at a time or something like that) but I woke up the next morning feeling like I’d torn my rotator cuff. I had to take two days off erging, icing and gulping down Aleve and Tylenol (and missing out on two days where it would have been nice to get out on the boat) but by Sunday night I was fine again. Again this morning, I’m a little sore in that shoulder – not as bad as last Saturday, but still enough to worry.

My goal is to be ready in spring to race again. That means this winter I want to be able to do some very long (over 16km) LSD (long slow distance) erg sessions, and also keep my speed up through interval work and fartlek, again on the erg. I’m starting to feel like this might be possible. I’m even working on improving my technique – I never had a forward lean, mostly because my big fat gut gets in the way, but I’m working on that. I’m also trying to stop splaying out my legs and keep them down the center of the boat, but I’m having some anatomical problems with that.

A long boat on a short car

One of the problems with my car is that the gap between the roof rack bars is so short. I bought a v-rack so that I wouldn’t be supporting the boat at two points near the middle and having it flexing all over the place, but the fact that such a long object is supported by two bars very close together means that the v-rack itself bounces up and down, or more accurately pivots forward and back, and places a lot of stress on the bars of the rack. It makes a lot of noise as it flexes, and I’m continually worried that the rack is just going to tear out as I go over a bump.

So today I took some action. I bought a couple of Seattle Sports “Hood Loops”, which are little nylon loops with a grommet on the end that you can attach using one of the quarter panel bolts under the hood of your car. I also bought a couple of “Quick Loops” from the same company. They’re a similar idea except instead of bolting them to the car, you just close them in the rear hatch and a soft but strong piece of plastic tubing prevents the loops from coming back out. Those are more experimental – once I figure out exactly where I want them, I might replace them with something bolted or otherwise more permanently attached. I ran a rope from one Hood Loop over the v-rack and down to the other Hood Loop, and did the same in the back with the Quick Loops. I then put the boat on the rack and went for a short drive. The difference in stability is incredible. It’s so much more stable, and quieter. Also, when I take the rack off for the winter, I can flip the Hood Loops inside the hood out of the way, and take out the Quick Loops, and take the car to the car wash.