May 2010 Archives

還記得 IO::All 的 A Tiny Web Server 嗎:

perl -MIO::All -e 'io(":8080")->fork->accept->(sub { $_[0] < io(-x $1 ? "./$1 |" : $1) if /^GET \/(.*) / })'

perlbrew PATH in Emacs.app

| No Comments | No TrackBacks

Emacs.app on Mac is not launched with the same $PATH set from bashrc/cshrc, which means perlbrew cannot work without some special treatments. One common problem is that cperl-perldoc will not be able to find the module document correctly. If you’re experiencing it, keep reading.

perlbrew problem with Net::DNS

| No Comments | No TrackBacks

If you're on Mac, using perlbrew and try to install Net::DNS, you might see it fail with this error message:

ld: in netdns.a, archive has no table of contents
collect2: ld returned 1 exit status
make: *** [blib/arch/auto/Net/DNS/DNS.bundle] Error 1

I'm not sure what causes it yet but I'm guessing that I need to play with some LD_LIBRARY_* variables since perlbrew installs perl to $HOME. Before it's fixed, heres' an work-around:

ranlib netdns.a

Execute that command after you see the ld error. After that, proceed the installation with:

make
make test && make install

You should see the tests are passing just fine.

Daily Awesomeness

| No Comments | No TrackBacks

Interesting fact: Twitter search "java hate", almost all tweets in the result are referring to the programming language. On the contrary, Twitter search "java love", they are all talking about the coffee.

That is really awesome.

BTW Is there a good way to do a "twitter fight" ?

Install all used modules at once

| No Comments | No TrackBacks

Ever since perlbrew was made useful, switching among different versions of perl makes it painful to re-install the required modules over and over. That's why I wrote this module-used program to rescue me.

The usage of module-used is heavily inspired by tokuhirum++'s cpan-outdated program:

cd /to/my/awesome-project
module-used

That gives you a list of module names which are found to be used in some source files under current directory. It can then be piped to xargs cpan -i to perform bulk module installation:

module-used | xargs cpan -i
module-used | xargs cpanm

Although cpanm --installdeps is doing basically the same thing here, this program is also helpful for module authors to get a list of names for their Makefile.PL or Build.PL, which might not be there in the first place if the current project is not planed to be uploaded to CPAN.

The module-used program itself uses Module::ExtractUse and List::MoreUtils , install them first, and the the program should be ready to run.