Monday, September 28th

2009 vs 1959 Crash Test

50 years of auto safety shown in one crash (YouTube).

Jim on 09.28.09 @ 08:53 AM ET [link]


Sunday, September 27th

The Trouble With Perl

Perl is a great language. It's easy to throw together scripts to do amazingly complicated things. Sure, the syntax is arcane, and there's a steep learning curve, but that just adds to the fun, right?

Well, the other day I was throwing together just such a script and spent several hours struggling through a couple of Perl's idiosyncrasies. Allow me to share them with you.

First is the annoying prototype for sprintf():


my @a = ("%s|%s\n", "apple", "banana");
printf(@a);
> apple|banana

my $s = sprintf("%s|%s\n", "apple", "banana");
print $s;
> apple|banana

my $s = sprintf(@a);
print $s;
> 3


This behavior is due to the fact that sprintf() expects its argument to be in scalar context first. I can't think of a good reason why this was done. And to rub salt in the wound, there isn't any way to force list context instead of scalar context. Bad, bad, bad.

The second idiosyncrasy:


my $hr = {a=>apple, b=>banana};

print @{$hr}{("a","b")}, "\n";
>applebanana

print $hr->{("a","b")}, "\n";
>


The syntax for slices of hash references, i.e. $r->{(some array)} just plain doesn't work. You need to use the alternate syntax: @{$r}{(some array)}. Maybe Larry Wall had a good reason to do this, but it's the sort of thing that gives Perl a bad name. I shouldn't need to spend hours figuring out why a syntactically legitimate construction returns nothing.

Jim on 09.27.09 @ 07:52 PM ET [link]


Sunday, September 20th

Dr. Horrible Rules

I was delighted to hear that Dr. Horrible's Sing-Along Blog won an Emmy. It's a short 45 minute mini-musical starring Neil Patrick Harris as an aspiring super-villain who wants to take over the world and meet his dreamgirl.

For those of you who have problems with the Hulu link, the full video is on YouTube, but is broken into several acts due to YouTube's length limitations. Here is Act 1 Part 1.

Jim on 09.20.09 @ 08:37 PM ET [link]



Email: jim@jimandbarb.DELETETHISPART.net
(please remove the DELETETHISPART before sending me mail!)