
perl
文章平均质量分 68
itech_001
这个作者很懒,什么都没留下…
展开
-
perl模块安装
转自:http://www.mike.org.cn/blog/index.php?load=read&id=643 Perl 到了第五版增加了模块的概念,用来提供面向对象编程的能力。这是 Perl 语言发展史上的一个里程碑。此后,广大自由软件爱好者开发了大量功能强大、构思精巧的 Perl 模块,极大地扩展了 Perl 语言的功能。CPAN(Comprehensive Perl Archiv原创 2013-03-24 19:21:59 · 602 阅读 · 0 评论 -
perl的logwrapper
对任何的函数将标准输出和错误输出重定向到对应的log文件。对任何的函数记录函数运行的时间。 代码:#!/usr/bin/perluse warnings;use strict;no strict "refs";sub testLogToStd{print "Test stdout : \n";open LOG,"> 2.txt";select LOG;print "just a test\n";#原创 2013-03-24 19:40:08 · 505 阅读 · 0 评论 -
perl常量+多维数组+变量的初始化
代码: use strict; use warnings;my $test = "asdf";print "${test}_test2\n";#constantuse constant { AAA => "aaa", BBB=> "bbb", MIN_TOTAL => 12, SCORE_PASS => 90, SCORE_RED => 70,};print AAA;原创 2013-03-24 19:40:10 · 678 阅读 · 0 评论 -
perl-cgi基础
代码: http://xxxxx/cgi/perl-cgi.cgi?name=itech&url=itech.cnblogs.com&p1=test1#!/usr/bin/perl -wT#should use strict and warnninguse warnings;use strict;use CGI;#to debug erroruse CGI::Carp qw(warningsToB原创 2013-03-24 19:40:14 · 570 阅读 · 0 评论 -
perl-cgi-form
一 此cgi既是提交前的form,也被用来处理form的提交来自:http://www.devdaily.com/perl/perl-cgi-example-scrolling-list-html-form 代码: (多选listbox-Multiple-choice SELECTs实例)不带参数时即为form:http://xxxx/cgi/perl-cgi2.cgi 当点击form的subm原创 2013-03-24 19:40:17 · 743 阅读 · 0 评论 -
perl-cgi命令行调试
参考: http://docstore.mik.ua/orelly/linux/cgi/ch15_03.htm http://stackoverflow.com/questions/2224158/how-can-i-send-post-and-get-data-to-a-perl-cgi-script-via-the-command-line http://search.cpan.org/~l原创 2013-03-24 19:40:21 · 752 阅读 · 0 评论 -
perl中调用cgi
参考:http://www.willmaster.com/library/manage-forms/using_perl_to_submit_a_form.php http://www.oschina.net/code/snippet_12_854 有时需要在perl中非交互地调用已有的cgi来完成一定的功能,此时需要模拟一个http请求来调用cgi。 get方式调用: 1 use H原创 2013-03-24 19:40:23 · 628 阅读 · 0 评论 -
perl-cgi高级
一 CGI.pm中的方法(routines)调用 1. CGI.pm实现了两种使用方法,分别是面向对象的方式和传统的perlmodule方法的方式。 面向对象的方式: #!/usr/local/bin/perl -w use CGI; # load CGI routines $q = CGI->new;原创 2013-03-24 19:40:28 · 699 阅读 · 0 评论 -
perl去除字符串前后的空格
使用正则表达式分两步走: 先去掉前面的: $a=~s/^ +//; 在去掉后面的: $a=~s/ +$//; 一步就可以: s/(^s+|s+$)//g; 删除字符串末尾的换行:chomp函数通常会删除变量里包含的字符串尾部的换行符。它是chop函数的一个略微安全些的版本,因为它对没有换行符的字符串没有影响。更准确地说,它根据了解$/的当前值删除字符串终止符,而不只是最后一个字符。和chop不同,原创 2013-03-24 19:40:30 · 1774 阅读 · 0 评论 -
perl读取文件
1)文件读取的3中方法 按行读,存入标量while () { print; }按行读,存入数组@array = ;读入整个文件 ,存入标量$string = do { local $/; ; }; 2)读文件实例open (EP,"/etc/passwd");while () {chomp;print "I saw $_ in the password fi原创 2013-03-24 19:40:37 · 691 阅读 · 0 评论 -
perl-cgi-form2
代码: #!/usr/local/bin/perl use CGI ':standard'; print header; print start_html("Example CGI.pm Form"); print " Example CGI.pm Form\n"; print_prompt();原创 2013-03-24 19:40:40 · 683 阅读 · 0 评论 -
perl命令+关键字
http://www.garybeene.com/vb/tut-per2.htm 完!原创 2013-03-24 19:40:46 · 788 阅读 · 0 评论 -
安装你自己的perl modules
安装你自己的perl modules。当没有root权限的时候,需要安装perl modules到自己的home目录下。来自:http://servers.digitaldaze.com/extensions/perl/modules.htmlInstalling Perl5 Modules LocallyNormally, the Perl5 module installation原创 2013-03-24 19:40:51 · 907 阅读 · 0 评论 -
perl的排序和比较
来自:http://www.perlfect.com/articles/sorting.shtml perl 比较操作符列表: NumbersStrings lt原创 2013-03-24 19:40:53 · 612 阅读 · 0 评论 -
在vim中使用perltidy美化perl代码
格式优美的perl代码不但让人赏心悦目,而且可以方便阅读.perltidy的是sourceforge的一个小项目,在我们写完乱七八糟的代码后,他能像变魔术一样把代码整理得漂漂亮亮,快来体验一下吧!!!perltidy 主页: http://perltidy.sourceforge.net/perltidy.html安装方法:进入解压后的目录,然后执行一下命令perl Makefil原创 2013-03-24 19:41:09 · 822 阅读 · 0 评论 -
perl脚本的目录
http://stackoverflow.com/questions/5703705/print-current-directory-using-perl?rq=1 1)The following get the script's directory, which is not the same as the current directory. It's not clear whic原创 2013-03-24 19:41:11 · 714 阅读 · 0 评论 -
perl通过文件锁让脚本单实例运行
原文地址:http://blogread.cn/it/article/743?f=wb 用Perl写了一些监控脚本,放在crontab中调度执行。有时候会发现一个脚本运行时间过长,会同时跑起多个实例,因此有必要为脚本加上控制,只运行一个实例。最简单自然的想法,在脚本中检查并创建一个空的lock文件,脚本结束时再删除。通过判断文件是否存在的方式来判断脚本是否已经运行。不过这样做有个bug原创 2013-03-24 19:41:16 · 1094 阅读 · 0 评论 -
Perl eval函数探讨
转自:http://weidagang2046.blog.51cto.com/246444/45923/ Perl 作为一种脚本语言可以实时地生成和执行代码。这种特性可以把代码的编译推迟到运行时,所以又称为“动态代码”。另外, Perl 也如 Java 、 C++ 一样提供了异常处理机制。本文将初步探讨Perl 中实现动态代码和异常处理机制的函数: eval 。如有错误不足,欢迎讨论和批评指正。原创 2013-03-24 19:40:05 · 684 阅读 · 0 评论 -
perl面向对象
Perl面向对象 首先让我们来看看有关 Perl 面向对象编程的三个基本定义: 1. 一个“对象”是指一个“有办法知道它是属于哪个类”的简单引用。(对象就是引用变量) 2. 一个“类”是指一个“有办法给属于它的对象提供一些方法”的简单的包。(类就是包) 3. 一个“方法”是指一个“接受一个对象或者类名称作为第一个参数”的简单的子程序。(类的方法就是第原创 2013-03-24 19:39:34 · 508 阅读 · 0 评论 -
Perl资料
一 官网 http://www.perl.org/ 二 编辑器notepad++:http://notepad-plus.sourceforge.net (编辑perl文件)komodo edit: http://www.activestate.com (编辑和运行perl文件)perl-express: http://perl-express.com/ (可以调试perl)原创 2013-03-24 19:24:47 · 495 阅读 · 0 评论 -
Perl IDE之Perl Express和Eclipse+EPIC+PadWalker
一 初级1)Notepad++ (编辑和查看Perl)2)Komobo Edit (编辑和执行Perl) 二 高级A Perl Express主页:http://www.perl-express.com/使用: 很简单B Eclipse+EPIC+PadWalkera) 下载解压Eclipseb)下载EPIC插件之设置 (help->install new software) c)下载EPIC原创 2013-03-24 19:24:49 · 709 阅读 · 0 评论 -
perl正则表达式[转]
一、简介二、匹配操作符三、模式中的特殊字符1、字符2、字符 []和[^]3、字符 +,*和?4、转义字符5、匹配任意字母或数字6、锚模式7、模式中的变量替换8、字符范围转义前缀9、匹配任意字符10、匹配指定数目的字符11、指定选项12、模式的部分重用13、转义和特定字符的执行次序14、指定模式定界符15、模式次序变量四、模式匹配选项1、匹配所有可能的模式(g选项)2、忽略大小写(i选项)例3、将字原创 2013-03-24 19:24:56 · 463 阅读 · 0 评论 -
Perl基础
一 perl文件1)文件第一行#!/usr/bin/perl,用来在类Unix系统上指定perl执行程序;2)#开始的行表示注释;3)use strict;对perl进行额外的检查,强迫你使用my定义变量,字符串必须使用单引号或双引号,引用其他的package的变量时变量前加package名字;4)use warnings;打开warning开关,不忽略warnings,等价于 u原创 2013-03-24 19:25:00 · 459 阅读 · 0 评论 -
perl的subroutines
一 subroutines1)定义 sub NAME {...} . 不需要指定参数和返回值。函数内使用@_来访问函数传入的参数,一般函数内使用local( $var, $var2, $var3) = @_或my( $var, @vars) = @_;来访问函数的传入参数。如果没有使用return的话,默认地最后一条语句的值作为函数的返回值。$_[0]表示第一个参数,$_[$#_]表示最后一个原创 2013-03-24 19:25:02 · 541 阅读 · 0 评论 -
perl的package和module
一 package1) package 相当于C++中的namespace,不同的package下可以定义相同的变量和subroutines;2)在一个程序中可以定义多个package,每个package有一个单独的symboltable,每个symboltable中包含了此package中的变量和subroutines;3) package mypack; 此语句定义一个名为mypa原创 2013-03-24 19:25:05 · 617 阅读 · 0 评论 -
perl读写文件和命令行解析
一 读写文件实例: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->use strict;use warnings;sub open_display_file{ # the filename should be passed in as原创 2013-03-24 19:25:07 · 552 阅读 · 0 评论 -
perl的array和map/hash
一 array1)实例Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->use strict;use warnings;my @myarray = (123,"hello", 456, 'guy');foreach(@myarray){原创 2013-03-24 19:25:09 · 459 阅读 · 0 评论 -
perl的map函数
perl的map函数的使用: 语法map EXPR, LISTmap BLOCK LIST 定义和使用对list中的每个元素执行EXPR或BLOCK,返回新的list。对每一此迭代,$_中保存了当前迭代的元素的值。 返回值如果返回值存储在scalar标量中,则代表map()返回数组的元素个数;如果返回值存储在list中,则代表map()函数的数组;原创 2013-03-24 19:28:12 · 587 阅读 · 0 评论 -
perl的USE和require
相同:都可以用来引用module(.PM)。 不同:1) 区别在于USE是在当前默认的@INC里面去寻找,一旦模块不在@INC中的话,用USE是不可以引入的,但是require可以指定路径; 2)use引入的名称不需要后缀名,默认找.PM文件,而require需要后缀名,且后缀名可以为.PM或.PL; 实例:c:\perl目录下3个文件如下(且module文件的最后必须有1原创 2013-03-24 19:28:21 · 443 阅读 · 0 评论 -
Perl调用外部命令的方式和区别
Perl调用外部命令的方式和区别转自:http://hi.baidu.com/develop_skill/blog/item/d69bc0cbf010da4ff31fe72b.html主要的方式简述如下:1. system("command");使用该命令将开启一个子进程执行引号中的命令,父进程将等待子进程结束并继续执行下面的代码。2. exec("command");效果同system命原创 2013-03-24 19:28:24 · 474 阅读 · 0 评论 -
perl使用xml::simple来读写xml
一 读xml1)xml实例Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->xml version="1.0" encoding="UTF-8"?>employees> employee age = "30"> name>linux原创 2013-03-24 19:30:44 · 674 阅读 · 0 评论 -
perl的INC设置
perl中的INC变量中包含了所有的perl module的查找路径。可以使用perl -V 来查看INC的值。 1)默认地INC如下: @INC: C:/Perl/site/lib C:/Perl/lib .2)设置环境变量PERL5LIB来增加到INC,例如: set perl5lib=c:\perllibs 在设置perl5lib后如下, %原创 2013-03-24 19:31:16 · 519 阅读 · 0 评论 -
perl的引用和->
常见数据类型的引用定义: 数据类型 定义 举例 标量变量 \$Var $Pointer = \$Var 数组 \@Array $Pointer = \@Array 哈希变量 \%Ha原创 2013-03-24 19:32:02 · 525 阅读 · 0 评论 -
perl模块安装自定义路径和使用
一 安装perl模块到非自定义目录 How do I get MakeMaker and Module::Build to install to the same place?Module::Build, as of 0.28, supports two ways to install to the same location as MakeMaker.1) Use INSTALL_BASE /原创 2013-03-24 19:38:28 · 5370 阅读 · 0 评论 -
perl的Getopt::Long和pod::usage
代码:需要显式地定义变量且初始化。例如optionX。如果没有定义变量且显式初始化,且没有在命令行指定选项,则选项对应的变量将为未定义。 #!/bin/perl-5.8.3/bin/perl$use warnings;$use strict;$use Data::Dumper;$use Getopt::Long;$use Pod::Usage;$our $g_opts;our $optionX='原创 2013-03-24 19:39:25 · 881 阅读 · 0 评论 -
Perl 之 use(), require(), do(), %INC and @INC
转自:http://perl.apache.org/docs/general/perl_reference/perl_reference.html use(), require(), do(), %INC and @INC Explained The @INC array@INC is a special Perl variable which is the equivalen原创 2013-03-24 19:41:21 · 1110 阅读 · 0 评论