From repeated experiment I have found out that if I put "use bignum;" before the subroutine, it breaks it but not if I put it after the subroutine.
The interaction is that bignum or one of the modules that bignum uses slows down the central until-loop so that it is many times longer than eight microseconds. This breaks it because the subroutine is supposed to measure the number of central until-loop cycles in eight microseconds. I think that bignum slows down the maths involved.