Perl使用总结

1 从CPAN安装模块

http://www.cpan.org/

搜索模块

找到后,安装,例如:

perl -MCPAN -e 'install HTML::WikiConverter'

2 debug

perl -d program_name
perl -d:Ptkdb program_name

需要Kt和Devel::Ptkdb,注意大小写,我安装的时候装了个小写,解决办法使用ln -s创建一个符号链接到小写。

http://perldoc.perl.org/perldebug.html

3 判断文件是否存在

if -e

http://perldoc.perl.org/functions/-X.html

4 1; in perl file

The file must return true as the last statement to indicate successful execution of any initialization code, so it's customary to end such a file with 1; unless you're sure it'll return true otherwise. But it's better just to put the 1; , in case you add more statements.

http://perldoc.perl.org/functions/require.html

1 in the end of module means that module returns true to use/require statements. It can be used to tell if module initialization is successfull. Otherwise use/require will fail.

http://stackoverflow.com/questions/1940182/what-does-1-mean-in-perl

5 shift

shift and unshift do the same thing to the left end of an array thatpop and push do to the right end.

http://perldoc.perl.org/functions/shift.html

6 列出文件entry

$::dir="\.";
opendir( CONF, $::dir ) or die $!;
while( $::config = readdir( CONF ) ) {
        print "Traverse : $::config\n";
        next if( $::config !~ /([^\/]+)\.conf$/ );
        #$::config = readdir ( CONF );
        print "Found : $::config\n";
}
http://perldoc.perl.org/functions/readdir.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值