Stupid Regexp Trick: Fail on match

I found myself one day trying to come up with a regexp that matched

m/ \G \s* (?:
        (?<oct> 0b[01]+ | 0[0-7]+ | 0x[[:xdigit:]]+ ) |
        (?<float> [+-]?(?=\.?\d)\d*\.?\d*(?:e[+-]?\d+)? )
    (?! \w )

where the <oct> capture represents things that need to be run through the oct built-in, and the <float> capture comes from perlfaq4.

The problem here was t…

Stupid perldoc-search trick

Perl's copious documentation is one of the things that keeps me using it. But a pretty good idea where to start looking, can be like finding the proverbial needle in a haystack.

Fortunately, we have Joshua ben Jore's perldoc-search, which will find anything you can specify as a regular expression, and that Perl itself can find.

Unfortunately, this can sometimes be a bit too much. I generally have several Perl kits unpacked in my home direc…

Son of MacPorts openssl versus Perl

This post is a follow-up to MacPorts openssl versus Perl. That post told of a problem with a recent MacPorts openssl upgrade, and gave a workaround.

The right thing to do, however, is to use the current openssl. That involves finding all Perl modules that use openssl and re-installing them.

To do this, I wrote a small Perl script that traversed @INC looking for binary files. It spawned the file command to determine whet…

MacPorts openssl versus Perl

This is only of interest to Mac users who link their Perl against

This morning I found that Perl code that used LWP::Protocol::https was failing, but only when run by the test harness.

After some flailing around I managed to track this to the fact that I had just updated MacPorts, and taken openssl from 1.0.2f_0 to 1.0.2g_0. I still do not know the precise cause of the failure, but it was exposed by the fact that the test harness (whether ExtUtils::MakeMaker or Module::Build) set PERL_DL_NONLAZY=1.

Stupid state trick

Occasionally I find myself writing a Perl subroutine that uses a module that no other part of the code needs. This subroutine may be called multiple times, or not at all. At some point I wondered if putting some logic around the require statement would be faster than just calling it every time. require() is idempotent, after all. You could do something like $counter++ or require Foo;, but the variable has to live somewhere outside the subroutine. Not neat.

It occurred to me that, given P…