[perl #117265] do most glob \0 checks in the same place

and before we do much processing