
Perl
文章平均质量分 75
bonny95
行至水穷处,坐看云起时。
展开
-
Perl中的特殊变量
Perl中的特殊变量1. $&, $`,$ 用在模式匹配中$& 用来存放匹配中的值$` 用来存放匹配中之前所有字符$ 用来存放匹配中之后所有字符如:#!/usr/bin/perl -wif("Hello good there,neigbor hello" =~ /S(w+),/){ print "That actually matched $&. ";原创 2009-01-06 15:16:00 · 961 阅读 · 0 评论 -
Perl/Tk Menus: Past, Present and Future
原文:http://www.foo.be/docs/tpj/issues/vol4_2/tpj0402-0016.html原文中图片全部挂掉,估计时间太久没人维护了……因此出于抢救知识的目的转载此文。PREVIOUS TABLE OF CONTENTS NEXT Perl/Tk Menus: Past, Present and Futur转载 2011-11-18 11:09:20 · 1147 阅读 · 0 评论 -
Shell浮点数运算
<br />Shell本身不支持浮点数运算,(())之类的数学运算符只能进行整数运算。要想在shell中运算浮点数,只能借助于bc, Awk或者Perl。 如<br />a=0.1b=0.2c=$(echo "$a+$b" | bc -l) <br />或者<br />perl -e "print STDOUT $a + $b;" <br /> <br />需要注意的是,如果数学表达式中有负数,则必须确保运算符(+ - * /)与其前后的表达式之间至少有一空格。如:<br />[bonn@bonn原创 2011-05-03 22:27:00 · 3348 阅读 · 0 评论 -
Perl的library设置
<br />参考链接:http://stackoverflow.com/questions/841785/how-do-i-include-a-perl-module-thats-in-a-different-directoryhttp://stackoverflow.com/questions/185114/how-do-i-use-a-perl-module-in-a-directory-not-in-inc<br /> <br />在Fedora/RHEL/CentOS中,perl 的library默原创 2011-05-16 16:46:00 · 3576 阅读 · 0 评论 -
Debugging Perl
How to Debug Perl Library and Scripts? 1. Changing @INC - where Perl loads its modules (http://www.wellho.net/mouth/588_Changing-INC-where-Perl-loads-its-modules.html) The @INC array is a list of directories Perl searches when attempting to load modu原创 2010-11-16 17:31:00 · 598 阅读 · 0 评论 -
利用在线词典批量查询英语单词
进来遇到很多英语生词,工具书上给的解释错误百出,而很多在线词典不但可以给出某个单词的解释,而且有大量的示例,因此猜想利用在线词典批量查询这些单词。怎么实现呢?首要问题是如何自动获取某个单词的解释。搜索之后,发现可以用curl实现,如curl -s "http://www.google.com/dictionary?aq=f&langpair=en|en&q="$1"&hl=en" | html2text -nobs | sed '1,/^ *Dictionary/]/d' | head -n -5 | le原创 2011-01-02 00:27:00 · 12707 阅读 · 0 评论 -
用SOCKET来传输文件的PERL脚本
<br />From: http://www.cnitblog.com/gyn/archive/2006/04/06/8824.html<br /> <br />Client:<br />#!/usr/bin/perl #===============================================================================## FILE: file_trans_clt.pl## USAGE: ./f转载 2010-07-12 19:50:00 · 1275 阅读 · 0 评论 -
在Perl中使用Shell命令
Shell Commands vs. Perl ClauseWhile there are some occasions that using shell commands from Perl are justified, there are many more when they are not. Decide: use the shell OR use Perl. Mixing t转载 2010-03-02 16:20:00 · 1828 阅读 · 0 评论 -
Shell中直接调用perl命令
The -e option is handy for quick Perl operationsfrom the command line. Want to change all instances of "oldstring" inWiffle.bat to "newstrong"? Try perl -i.old -p -e "s/ oldstring/ newstrong/原创 2009-10-22 00:05:00 · 6836 阅读 · 0 评论 -
用PERL处理二进制标量
PERL Handling Binary Scalar1 [Question]:I adopt select()...sysread()...syswrite() mechanism to handle socket messages, where messages are sysread() into $buffer (binary) before they are原创 2009-03-12 16:53:00 · 2009 阅读 · 0 评论 -
Perl Notes(I)
Part I Programming Perl1 Perl Data Types1.1 Funny CharactersTypeCharacterExampleIs a name for:Scalar$$centsAn individual value (number or string)Array@@large原创 2008-12-29 09:17:00 · 1146 阅读 · 0 评论 -
PERL打印收到的Socket消息
PERL打印收到的Socket消息利用Perl的Select(),sysread()和syswrite()收到的消息将以二进制的形式存储到$buffer中,因此如果直接打印$buffer的内容将得到乱码。要将二进制内容转换为十六进制数串,则必须使用unpack()函数,即:my $hexstr=unpack("H*",$buffer);而此时如果打印$hexstr将得到一系列原创 2009-03-05 23:13:00 · 1453 阅读 · 0 评论 -
Perl数值转换
As always with Perl there is more than one way to do it. Below are a few examples of approaches to making common conversions between number representations. This is intended to be representational r原创 2009-03-05 09:16:00 · 1661 阅读 · 0 评论 -
Perl Notes(II)
Part II Network Programming With Perl1 Input/Output Basics1.1 FilehandlesFilehandles are the foundation of networked applications. In this section we review the ins and outs of filehandles. Even i原创 2009-01-13 14:08:00 · 1491 阅读 · 0 评论 -
How do I add a directory to my include path (@INC) at runtime?
How do I add a directory to my include path (@INC) at runtime?Here are the suggested ways of modifying your include path, including environment variables, run-time switches, and in-code statements:th转载 2009-01-13 14:05:00 · 967 阅读 · 0 评论 -
Perl Notes(III) -- Introduction To Berkeley Sockets
3 Introduction To Berkeley Sockets3.1 Basic Concepts3.1.1 Binary versus Text-Oriented ProtocolsBefore they can exchange information across the network, hosts have a fundamental choice to make. They ca原创 2009-01-13 23:13:00 · 1537 阅读 · 0 评论 -
Shell向Perl脚本中传递变量的方法
方法一:In shell using export to output a variable, and in perl using special variable %ENV to get shells variables.i.e.:--- shell box---$ /bin/ksh# export x=Foo# perl -e print $ENV{"x"}----------原创 2009-01-12 16:01:00 · 5412 阅读 · 0 评论 -
Tips about Regular Expression
In Vim, greedy matching is used by default. In order to use non-greedy matching, you can use \{-}, or \{-n,m}, such as: :/Q.\{-0,200}[IL].\{-0,2000}FF.In Perl, default matching is also greedy. To us原创 2012-11-17 12:39:21 · 679 阅读 · 0 评论