in reply to PDL and srand puzzle

The uncontrollable mass-import of core subroutine names by PDL is indeed something ... special. I guess it is fair to attribute it to the fact that big parts of it were written in the previous century, when extensive @EXPORT lists were rather popular. While it is f**cking convenient most of the times, apparently it can bite you.

That said, the combination of srand and rand is special also by two other facts: 1) the functions are not independent of each other, and 2) PDL did override srand but not rand, it has a function random instead. This might be indeed the only pitfall of PDL's exports: I would expect all others to behave like their CORE equivalents.

I see two ways around it (that is, without changes in PDL):

The following two examples give consistent (but different) results each:

perl -MPDL::Lite -E "srand(3); say rand();" perl -MPDL -E "srand(3); say random();"

Anecdote: Once I got bitten by export list the other way around: One of my programs also used Math::Trig. This overrides a list of (non-core) functions also provided by PDL, but ... of course it doesn't provide the magic (and gave strange error messages) when called with an ndarray as an argument.