A simple numerical overflow had been causing an error in my code for ages, and I just found it. The problem arose from using numbers greater than 2^32 in Perl. I’ve become so used to 64-bit systems that I’d forgotten to check for it.
I got sed to do something clever today, though sadly the cleverness was not mine. I tried to solve the problem myself and although in the process I learned a great deal about sed, I had to resort to copying the answer.
sed -e ‘
sed -e ‘
sed -e ‘
‘ -e N -e ‘}’
The ‘r’ command actually outputs the file just before reading a new line to the pattern buffer (or at EOF). That can be forced in mid-script by ‘n’ or ‘N’, and while ‘n’ will also print the
buffer before ‘r’ does its thing.
Perl is not noted for its leanness but today I finally ran some little tests to see just how much memory it was devouring. I use some OO Perl code to process image files, there is a base class Image::Med from which are derived Image::Med::DICOM, Image::Med::Analyze, and a few others. I store each DICOM element in an object instantiated as a hash; it’s of class Image::Med::DICOM::DICOM_element which is derived from a base class Image::Med::Med_element. The inheritance works quite well and I’m able to move most of the functionality into the base classes, so adding new subclasses for different file formats is reasonably easy.
“Apache recognizes all files in a directory named as a ScriptAlias as being eligible for execution rather than processing as normal documents. This applies regardless of the file name…”
A dim light comes on. httpd has been trying to execute the js file, because I told it to, with the ScriptAlias directive in my httpd.conf file, which says that everything in cgi-bin is a script:
ScriptAlias /cgi-bin/ “/Users/ahc/public_html/cgi-bin/”
I’ve often wanted to have more than one optional argument to a Perl subroutine. For instance I have a utility function printHash() to which I pass a pointer to a hash (associative array). It prints the hash contents in a formatted box, with an optional description at the top.
every time. But t
hat is Actual Work, and anyway it’s tedious to create a single-element hash whenever I just want to dump a full hash with a comment. Usually, this is an image file header and the file name as a comment. So I changed printHash() to overload the second argument: if it’s a hash, use it as a hash, if it’s a scalar, use it as a comment. This is questionable programming practice but oh well.