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 : $::confign"; next if( $::config !~ /([^/]+).conf$/ ); #$::config = readdir ( CONF ); print "Found : $::confign"; }http://perldoc.perl.org/functions/readdir.html (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |