Aha. The tests are failing and it is due to a bug in perl 5.8.0, if I recall, related to taking weak references. This bug is fixed in perl 5.8.something and is not related to Test::Deep - it can break other things too, although not much uses weak references.
So you have 2 choices,
- Install the module anyway (man CPAN to find out how to ignore failing tests or just install it by hand), I'm not sure exactly what will break but it might be that the Apache stuff doesn't do anything that will cause a problem.
- Upgrade your Perl. There are lots of other things fixed between 5.8.0 and 5.8.8 (the latest 5.8 release). This will prevent you running into mysterious bugs with other modules too
Finally, for the infinite loop, I just glanced at the script you posted and it seems that this script is just reimplementing a part of CPAN.pm. It would be better to just get CPAN.pm to do all the work here by telling it to install "all these modules and their dependencies". Instead, the script uses CPAN.pm but ends up in an infinite loop when Test::Deep's tests fail.