Fixing Perls CPAN on Mac OS X Leopard
One of the main languages I use for programming quick fixes is called "Perl". One thing that makes it so powerful is that there exists a huge number of modules for helping you do things that Perl doesn't do itself right out of the box. The easiest way to install the additional modules is with a core module called CPAN. Basically, you just tell the CPAN module what you want to install and it goes out to the web to find what you want, downloads it and then installs it. While it's not difficult to do all that stuff yourself, it's much faster to let CPAN handle all the steps for you automatically. At least, as long as it works.
While trying to add a new module today at work, CPAN couldn't manage to get to the outside world. Every time it tried to get a file, it would take so long CPAN timing out and give up. I was browsing the net and could actually get to the files CPAN was looking for directly with my browser. So, I knew it wasn't an issue with the connection, but had to be something to do with CPAN itself. This is a classic example of how hunting for one little computer issue can take a huge amount of time. I spent over two hours tracking down what was going on. It turns out that one of Perl's configuration files was set so that FTP processes wouldn't be in "Passive Mode". The fix was to open the file "/System/Library/Perl/5.8.8/Net/Config.pm" and change the line: ftp_int_passive => 0, to: ftp_int_passive => 1,
After changing that setting, CPAN is working like a champ. The two parts of this that boggle the mind: 1) that a single digit makes such a big difference and 2) that it's actually possible to figure that out the issue with that one digit and what to do about it thanks to the net. (Note: the main reason for this post is to hopefully help other people who have the same problem find the answer in less than two hours. This fix is for Mac OS X 10.5 Leopard when CPAN times out trying to load files like "01mailrc.txt.gz".)