Perl

CPAN "couldn't Untar" error

I tried to install something via CPAN, but kept getting this error. Even "perl -MCPAN -e 'install CPAN'" gave such error:

Using Tar:/bin/tar xvf /root/.cpan/sources/authors/id/A/AN/ANDK/CPAN-1.9402.tar:
Couldn't untar /root/.cpan/sources/authors/id/A/AN/ANDK/CPAN-1.9402.tar

It wasn't permission, because I was running from root. Maybe the memory. Since this is a OpenVZ container, we would check the /proc/user_beancounters

# cat /proc/user_beancounters

Install Net::Packet

We were not able to install the CPAN module Net::Packet. The error messages indicated that it could not find Net::Libdnet module.

Next, we tried to install Net::Libdnet, but got the error "Libdnet.xs:37:18: error: dnet.h: No such file or directory". That means, we are missing a libdnet.

So, we installed libdnet through yum (from "epel" repos):

# yum install libdnet libdnet-devel

("epel" repos is the Fedora extra package repos).

Perl Socket Shutdown and Close

This discussion http://www.perlmonks.org/?node=108244 explains nicely that we need to do shutdown and close after we are done with a socket:

shutdown on a socket is similar to close on a pipe in what information it gives to the program on the other side. But it does not close the file handle.

WWW::Curl

I tried to install this module WWW::Curl via cpan, but failed on both Centos 4 and Centos 5. Instead of digging for the fix, I just enabled rpmforge repository, and installed through yum:

# yum install perl-WWW-Curl

LWP with Proxy

LWP Cookbook has the example on how to use proxy for HTTP request.

Here are some more examples:

To connect to an HTTP proxy using LWP, here is what you do:

Perl Thread

Here are some discussion and informaton on Perl thread programming:

 

 

Module::Starter Over h2xs

I used to use h2xs to start my Perl extension modules. Now I am testing Module::Starter.

Before we start, here are some modules to install

Convert Simplified Chinese to Traditional Chinese in a Drupal Project

If you have a Drupal website in Simplified Chinese, and now you want to to convert it into Traditional Chinese, or the other way around, here is how you can do it:

How to Install a Perl Module at a Custom Location

If you don't have permission to install a Perl module into the system Perl directories, you will not be able to use CPAN or yum or atp-get etc to install the module. You have to manually install it. Here are the steps:

  1. Download the module's package from search.cpan.org
  2. Install the package:

    $ tar zxf module-name.tgz
    $ cd module-name
    $ perl Makefile.PL PREFIX=/your-custom-dir
    $ make
    $ make test
    $ make install

HTML::Encoding Dependencies

The locale library for at least utf-8 must be compiled before we attempt to install HTML::Encoding.

On Gentoo, we run "locale-gen" to compile the locales, after we have setup the locale options follow the notes at the bottom of Installing the Gentoo Base System.

On Red Hat/CentOS, we run "localedef" to compile definition files. For instance, you can do "localedef -c -f UTF-8 -i en_US en_US.utf8" to compile utf-8 of en_US.