2012年5月25日 星期五

How to Use CPAN to Install Perl Module and Script

CPAN stands for “Comprehensive Perl Archive Network”.   It provides many useful perl modules.

Method 1: manually install

(i) Download the tarball from CPAN

(ii) tar zxvf tarball

(iii) cd decompressed directory, then ‘perl Makefile.PL’.  It there is dependency error, go to step (i)

(iv) ‘make’, then ‘make test’, then ‘make install’.

Pro: Method 1 works both for install module (WWW::Extractor) and script (e.g. xls2csv)

Con: Method 1 is time consumping to deal with dependency error!!

 

 

Method 2: auto install Module

(i) type “cpan”,  set urllist by “o conf init urllist –> http://cpan.develooper.com/

(ii) install CPAN to install the updated cpan.   then “reload cpan”

(ii) perl –MCPAN –e ‘install module’   e.g. perl –MCPAN –e ‘install WWW::Extractor’

Pro: Method 2 solve the dependency issues by cpan automatically!!

Con: Method 2 only works with module,  NOT work with script, e.g. “xls2csv”!

Need to do perl –MCPAN –e ‘install K/KE/KEN/xls2csv-1.06.tar.gz’

Excel to CSV

CSV’s advantages are: (i) popular ascii format for data computing, processing, and plotting; (ii) built-in or plug-in support support from Gnuplot, Perl, Ruby, Python, and Matlab. 

CSV’s disadvantage is poor readable format, and not good for interactive processing.  On the contrary, Excel file format (xls) makes up this disadvantage. 

To take advantage of both CSV and Excel, we can use Excel (xls) as the user interface; and back-end processing uses CSV.  Therefore, we need a tool to convert xls to csv and vice versa.

CPAN provides both csv2xls and xls2csv. 

Go to CPAN and download xls2csv-xx.tar.gz

uncompressed it, and cd to the directory.

Do ‘perl Makefile.PL’,  then ‘make’, then ‘make test’, then ‘make install’

How to solve the dependency problem?  See next article for details.

What’s the advantage of CPAN xls2csv?  compared with other xls2csv (e.g. catdoc)? 

A. Better support for unicode (Chinese);  B. Better support for multiple worksheet

追蹤者