Tag Archives: Perl

batch install Perl modules

autobundle install …

Posted in Perl | Tagged , | Leave a comment

Auto installing perl modules depent on other modules with cpan program

cpan o conf prerequisites_policy follow o conf commit exit

or

$ export PERL_MM_USE_DEFAULT=1 $ cpan -i …

Posted in Linux, Perl | Tagged , | Leave a comment

在windows平台下在C语言中调用perl脚本

OS: Windows XP SP2 Complier:Microsoft Visual Studio C++ 2005

1. 下载并安装ActivePerl-5.8.8.819-MSWin32-x86-267479.msi安装包。 2. 用cpan安装ExtUtils::Embed模块. 3. 从cpan下载MExtUtils::Embed安装包,从中提取genmake脚本。 4. 安装ActivePerl 5.10. 5. 将系统中path环境变量中关于ActivePerl 5.10的环境变量去掉。 6. 编写调用perl脚本的c程序t.c。 7. perl genmake t.c 8. 将Makefile中的路径替换成ActivePerl 5.10的路径。 9. nmake 10. 将Config.pm, lib.pm, strict.pm复制到脚本所在目录。 11. 编写测试脚本。

t.pl: use strict; use lib ‘c:\perl510\lib’; use lib ‘c:\perl510\site\lib’;

use Digest::MD5 qw(md5 md5_hex md5_base64); my $digest = md5_base64(’12345′); print $digest; print … Continue reading

Posted in Perl | Tagged , , | Leave a comment

一个perl脚本

#!/usr/bin/perl use strict; use warnings; use Data::Dump qw(dump); my %h; while(){ chomp; next if /^$/; my @tmp = split / +/,$_; $h{$tmp[0].” “.$tmp[3]}=[] if !defined $h{$tmp[0].” “.$tmp[3]}; push @{$h{$tmp[0].” “.$tmp[3]}},$tmp[4], $tmp[7]; } while(my ($k, $v) = each … Continue reading

Posted in Perl | Tagged | Leave a comment

Perl的in-place的用法

perl -p -i.bak -e’s/abc/def/g’ test.txt

Posted in Perl | Tagged , | 1 Comment

Perl中正则表达式的特性

在Perl语言中,当正则式为空的时候,指的是前一次成功匹配的正则式。

Posted in Perl | Tagged , | Leave a comment

Perl语言中获取本机IP地址

使用Sys::HostIP包。 用法:

use Sys::HostIP; my $ip_address = Sys::HostIP->ip; print $ip_address;

Posted in Perl | Tagged , | Leave a comment

Ubuntu Linux 7.10 CPAN tips

When upgrade CPAN module in Ubuntu Linux 7.10, a problem occured: can not install new version CPAN. Sulotion:

install CPAN look cpan make make test make install exit

Posted in Perl | Tagged , , | Leave a comment

Add session support on Catalyst

Add the next line in the application class:

use Catalyst qw/Session Session Session::Store::FastMap Session::State::Cookie;

Posted in Misc | Tagged , | Leave a comment

Perl字符编码问题相关文章链接

关于Perl编程中涉及的字符集的问题,在网上搜索到几篇文章。

http://fuzhong1983.blog.163.com/blog/static/16847052009085482194/

http://www.izuren.com/2008/11/15/perl%E4%B8%AD%E7%9A%84%E5%AD%97%E7%AC%A6%E7%BC%96%E7%A0%81/

http://hi.baidu.com/zhaobz/blog/item/57e554da1b2a83d8b7fd4862.html

Posted in Perl | Tagged , | Leave a comment