rlucas.net: The Next Generation Rotating Header Image


Migrating to new rlucas.net domain for most blogging

Gentle reader,

This server has gotten so slow,
probably thanks to Philip's blog, that
I have finally decided to put up my own server elsewhere.  Other
reasons are:

  • I can't use vim here to edit my entries.
  • I hate the HTML munging that this blog software uses.
  • Despite
    the PageRank boost of the .harvard.edu domain, I have decided to opt
    for the branding aspect of my long-time username, rlucas, which has
    been the local part of my Internet email address since 1993 or

And so, I am putting on hold this, my
Berkman blog.  I do intend to keep using it for Harvard-specific
things, on occasion, but my technical notes and, newly, my startup and
VC related dispatches, will be found from now on at my rlucas.net blog.

[FIX] Perl DBI / DBD::Pg bind values rely on Perl's automatic numeric/string scalar conversion

Scenario: you are using DBD::Pg to interface with your database (perhaps directly through DBI, or through an abstraction layer like Class::DBI or DBIx::ContextualFetch) when you get an odd result:

DBD::Pg::st execute failed: ERROR: parser: parse error at or near [your string, or the part of your string that doesn't begin with leading digits] at …


DBD::Pg::db selectrow_array failed: ERROR: Attribute “yourstring” not found at …

If you look at the PostgreSQL query log, you'll see that “yourstring” was not properly quoted as a literal in the SQL delivered to the parser.

Since you've either been relying upon your abstraction layer or personally doing the Right Thing and binding your values with the “WHERE thing=? AND otherthing=?” syntax, you're quite confused — this should all be quoted.

The problem is that Perl has flagged that scalar as a numeric value, possibly because you used a numeric operator on it (like > or == instead of gt or eq). The solution is to upgrade to DBD::Pg 1.32 or to explicitly stringify your string as “$yourstring”.

Below is the bug filed with CPAN.

Mac OS X 10.2, Perl 5.6.0, DBD::Pg 1.22, DBI 1.45

Bind values appear to rely upon Perl's automatic numeric/string scalar conversion in order to determine whether or not to quote.

This bug was discussed on

my $dbh = DBI->connect(…); #connect to Postgres; no errors with SQLite
my $scalar = “abc”;
warn “scalar is greater than zero (and now considered numeric)” if $scalar > 0;
warn “dbh->quote(scalar) works ok: ” . $dbh->quote($scalar);
warn “but bind values do not:” . $dbh->selectrow_array(

Using a numeric operator on the scalar makes Perl auto-convert it to a number; this is interpreted by the magic in Pg.xs as rendering the scalar ineligible for quoting.

One solution is to bind those variables that must be text but might have been numberified with “$varname”, thereby stringifying them in the eyes of Perl.

FIX: "Undefined subroutine CGI::dump" crashes a formerly working script.

Possible scenario: you wrote an ancient script using the CGI.pm module by Lincoln Stein, and it ran fine on your old RedHat 6.2 box with Perl 5.00503 and an ancient version of CGI.pm.   However, after reinstalling your script on a newer box with Perl 5.6, or else after upgrading your perl and/or CGI.pm, your script is broken and says

Undefined subroutine CGI::dump

Answer: in version 2.50 of CGI.pm, CGI::dump was changed to CGI::Dump. Try:

perl -pi -e 's/CGI::dump/CGI::Dump/' yourscript.pl


Class::MethodMaker v2 dies with cryptic "Unknown error" in compilation with bad arguments to use / require

If you use Class::MethodMaker and have a subtle error in your

use Class::MethodMaker [ whatever…];

line, such as not quoting a bareword, you can end up with this error:

Unknown error
Compilation failed in require.
BEGIN failed–compilation aborted.

If this happens, scrutinize your “use” lines and especially your C:MM line.If you use Class::MethodMaker and have a subtle error in your

use Class::MethodMaker [ whatever…];

line, such as not quoting a bareword, you can end up with this error:

Unknown error
Compilation failed in require.
BEGIN failed–compilation aborted.

If this happens, scrutinize your “use” lines and especially your C:MM line.

[Gedankenexperiment] I have released EULAVirus 1.0 into the wild.

“I have created a computer virus and released it over the Internet.  It is named “EULAVirus” version 1.0.

“The virus takes the following actions, besides replicating
itself.  It seeds a pseudorandom number generator with a number
based upon the machine's unique characteristics, such that the PRNG
sequence will always be the same for the same machine.  Then,
during a dialog box, wizard, browser window, or other interactive
session (“dialog”) when certain key words and / or pixel combinations
are detected, it takes a “fingerprint” of the dialog based upon certain
characteristics, and uses the PRNG to determine whether to act on that
dialog.  The manner in which this is done ensures that for a given
dialog on a given machine, the same action will always be taken. 
If a dialog box is acted upon, the virus will cause all text to be
scrolled through, and an approval button to be “clicked” (it does so by
interacting with the operating system at a lower level).  This all
takes places nearly instantly, so that any human watching the computer
perform this will be unable to perceive what has occurred, beyond
perhaps a brief flash of the dialog on a slow computer.

“I have deleted all traces of the virus and any of its documentation
from all computers I control, but not before propagating it out to the
Internet.  It is spreading rapidly but it is exceedingly stealthy,
and it is engineered to avoid detection at all costs.  In order to
prevent its detection, I will not say which operating systems it runs
on, nor will I identify specific vectors of transmission.”

Now: can a EULA (end-user license agreement) ever again be considered legally binding?

FIX: SSH or telnet sessions timeout and drop connection on DSL or Cable modem behind NAT router

I use SSH for everything from tunnelling outbound mail in order to avoid port 25 blocks on the freenet providers (such as www.personaltelco.net) to simple terminal sessions.  Also, most all of the time I am hooked up via a DSL or Cable modem with a router in front of it playing NAT tricks to get me to the outside network.  After about an hour (sometimes less) the SSH just hangs; from a Mac OS X terminal session it's just unresponsive and needs to be killed, whereas on PuTTY on Windows, once it realizes the connection is no good it pops up a “Network error: Software caused connection abort” message.  The problem seemed to be worse with DSL from Verizon and Qwest, and seemed to be very mild with AT&T/Comcast cable in Cambridge, 02138 (advice: in Cambridge, you can't go wrong with the Comcast digital cable.  I was getting speeds of (I seem to remember) almost a megabyte per second down and could pull down entire ISOs in minutes; debian net install on an old p233 was disk i/o limited and not network limited by what I could tell.

Happily, the good people at DSL Reports (www.dslreports.com) have put together an FAQ on this subject including some specific configuration options and links to more info:


More on this as I determine if it actually works.

Update: So far, so good; a thunderstorm passing through caused a brief power cycle and that definitely reset the connection, but it seemed to hold otherwise, for example during lunch.  The real test will be leaving terminal sessions overnight.

Update: While looking for info on a superficially related problem, I came across this slashdot thread:


This may also provide some assistance to seekers of info on this topic.  However! importantly, you should also examine the lengthy parenthetical in http://blog.rlucas.net/ancient/info-what-happens-to-ssh-every-21115/ to determine if this is really your problem — the link to a TCP/IP theory page should help you as well.  This caveat is necessary because there are really two opposite problems that both manifest as “dropped ssh terminal sessions:” one, a NAT table on a cable/dsl router could be timing out (which argues for more frequently sending keepalive packets), or two, your connection could be flaking out briefly but coming back up fairly quickly (which argues against sending frequent keepalives).

[FIX] Adobe Reader v.5 fails to open PDF with "There was an error opening this document. A temporary file could not be opened."

If you see “There was an error opening this document.  A temporary file could not be opened.” when trying to open a PDF file, you may need to clean out C:Documents and SettingsUSERNAMELocal SettingsTempAcr*.tmp

Cheers to “gprellwitz” who suggests this here:


Jeers to the MSFT developer who decided that “Documents and Settings” with spaces and mixed caps was a better home directory prefix than “home”

BUG/FIX: Empty "script" tags may cause IE to display nothing

I use Microsoft Internet Explorer version 6 (IE6) on Windows 2000 when
I have to (much better to use Mozilla or Opera in my opinion; even some
of the Microsoft guys are now eschewing IE for security reasons). 
I tested a document that passed some pretty strict validation and was
showing up fine in Mozilla, under IE6.  The title appeared, but
the body was blank.  What?!

It turns out that the problem was independent of quirks mode on/off
(google for quirks mode if you don't know).  It was dependent upon
two “<script language='javascript' src='blah' />” tags in the
<head> section.  By changing the <script /> to
<script></script> (explicit closing tags), the body
reappeared OK.

[FIX] DBD::mysql installation on Red Hat 9 fails with "Unsuccessful Stat" messages.

If you go to install the Perl module DBD::Mysql on Red Hat 9 with MySQL 3.23 (and probably other versions as well), two gotchas might appear.  First, if the MySQL bin directory is not in your path, then you won't be able to have it pull the options automatically.  Make sure that when the Makefile.PL runs (either because you're running it or CPAN is) it can find and run mysql_config.


The second gotcha is that Red Hat shipped 9 with default LANG=en_US.UTF-8 in the shell environment.  This will cause your makefile to have some oddly malformed lines around line 89, and will cause a blizzard of these complaints:

Unsuccessful stat on filename containing newline at /usr/lib/perl5/5.8.0/ExtUtils/Liblist/Kid.pm line 97.


The solution, according to the kind David Ross at Linuxquestions.org, is to

export LANG=C

before running Makefile.PL. Many thanks.





[BUG] ActiveRecord woes with SQL Server odd names (spaces and brackets), ntext data types

ActiveRecord (latest versions of ODBC, DBI, and AR as of today
2005-12-01) seems to be having trouble with at least two things that
SQL Server 7 does:

1. The SQL Server adaptor (sqlserver_adaptor.rb) get_table_name sub
expects a name to have no whitespace in it.  The conditional and
regex need to be changed to look for bracketed names like [Poorly
Designed Table].  Then, the columns sub needs to know to take the
brackets off the ends of the names when it looks up the table by its
textual value.  To complicate this, according to
http://msdn2.microsoft.com/en-us/library/ms176027.aspx you can have
either double-quotes or square brackets as your delimiters in SQL
Server names, and you can even escape brackets by doubling.  I
have written hackish code that solves for simple [Dumb Name] tables but
not the whole enchilada, so I'm not posting it here yet.

2. The data type “ntext” seems to create memory allocation problems; I get an error of:

/usr/lib/ruby/site_ruby/1.8/DBD/ODBC/ODBC.rb:220:in `fetch': failed to allocate memory (NoMemoryError)

Running this on CYGWIN_NT-5.1 RANDALL-VAIO 1.5.19s(0.141/4/2) 20051102 13:29:13 i686 unknown unknown Cygwin on Win XP Pro.