Perl

Two commits of independent changes, bundled together to minimize stdenv rebuilds:
- more purity, attempt to fix #386
- enabling most tests (perl is very important to us, we should check it as much as possible)

I tested this via building stdenv on linux-x86_64, both applied to master and stdenv-updates.