Thanks for the quick fix! Using your code in WP 3.4.1, I got an "unexpected ';'" error. I tweaked it a bit as follows and everything works great (in addition to fixing the syntax, I upped the string length to 42 characters and replaced the three periods with an HTML ellipsis character):
if (strlen($title) > 42) $title = substr($title,0,42) . '…';