Perl,一种功能丰富的计算机程序语言,运行在超过100种计算机平台上,适用广泛,从大型机到便携设备,从快速原型创建到大规模可扩展开发。Perl借取了C、sed、awk、shell 脚本语言以及很多其他程序语言的特性,其中最重要的特性是它内部集成了正则表达式的功能,以及巨大的第三方代码库CPAN。
这几天一直在折腾Bugzilla,原以为应该挺简单的,却也是一波三折。下面是“被虐”的过程: 一、下载 由于不太习惯Linux的命令行下载方式,就先在本地的下载了当前最新的稳定版本Bugzilla3.6.1 ,然后通过scp上传到服务器上。解压至/usr/local/bugzilla。同时 在/var/www/html目录中创建一个symbolic link: # ln -s /var/local
对匿名哈希的创建与使用 #!/usr/bin/perl use warnings; use strict; 普通方法定义hash引用 my %gilligan_info = (   name => 'Gilligan',   hat => 'White',   shirt => 'Red',   position => 'First Mate', ); my %shipper_info = (  
    一直以来是用rsync来备份svn,最近恢复了一个2009年的SVN的备份。突然想还是用svnadmin dump 备份出来比较方便(这也是官方推崇备份方式,恢复起来有点慢),好管理。决定用perl 来实现(因为最近在学习perl):    备份的思路就是首先读取一个项目,然后全备,并且把版本写入到一个文件,差异备份脚本备份时读取这个文件的中的版本号,如果版本号不同,则备份。 全备份脚本:
使用的软件版本 DBI-1.609.tar.gz DBD-mysql-4.012.tar.gz 建议使用以上版本搭配,否则可能连接mysql错误 一、DBI的安装  wget http://www.cpan.org/modules/by-module/DBD/DBI-1.609.tar.gz  tar -zxvf DBI-1.609.tar.gz  cd DBI-1.609  perl Makef
什么是函数式编程 到现在我们已经讲了很多了,但还没有真正涉及到函数式编程. 目前所讲的所有特性 - 丰富的数据类型(rich data types), 模式匹配(pattern matching), 类型推导(type inference), 嵌套函数(nested functions) - 可以想象它们都可以在一种”超级C“语言中存在。这些特性当然很酷,它们使得代码简洁易读,减少bug,但是它们
  先是最常见的解释:   Use   1 use用于载入module   2 use在编译时验证module   Require   1 require用于载入module或perl程序(.pm后缀可以省略,但.pl必须有)   2 require在运行时验证module   其它区别:   use引入模块的同时,也引入了模块的子模块。而require则不能引入   use还调用了import静
如果字符串结尾有换行符,chomp 可以去掉它。这基本上就是它能完成的所有功能,如下例: $text = “a line of text/n”; #也可以由<STDIN>输入 chomp($text); #去掉换行符(/n)。 它非常有用,基本上你 的每一个程序都会用到它。如你将知道,这是将字符串末尾换行符去掉的最好方法。基于Perl 中的一条基本原则:在需要使用变量的地方,可以使用赋值表达式来代
system LIST system PROGRAM LIST Does exactly the same thing as exec LIST , except that a fork is done first, and the parent process waits for the child process to complete. Note that argument processi
You probably have some questions about Perl, and maybe some about this book, especially if you've already flipped through the book to see what's coming. So, we'll use this chapter to answer them. 1.1.
  1.2. What Does "Perl" Stand For? Perl is sometimes called the "Practical Extraction and Report Language" though it has been called a "Pathologically Eclectic Rubbish Lister" among other expansions.
  1.3. How Can I Get Perl? You probably already have it. At least, we find Perl wherever we go. It ships with many systems, and system administrators often install it on every machine at their site. I
  1.4. How Do I Make a Perl Program? It's about time you asked (even if you didn't). Perl programs are text files; you can create and edit them with your favorite text editor. (You don't need any spec
  1.6. Exercises Normally, each chapter will end with some exercises, with the answers in Appendix A. But you don't need to write the programs needed to complete this section as they are supplied with
  1.5. A Whirlwind Tour of Perl So, you want to see a real Perl program with some meat? (If you don't, just play along for now.) Here you are: #!/usr/bin/perl @lines = `perldoc -u -f atan2`;
  2.1. Numbers Though a scalar is most often either a number or a string, it's useful to look at numbers and strings separately for the moment. We'll cover numbers first and then move on to strings. 2
  2.2. Strings Strings are sequences of characters (like hello). Strings may contain any combination of any characters.[] The shortest possible string has no characters. The longest string fills all o
  2.4. Scalar Variables A variable is a name for a container that holds one or more values.[*] The name of the variable stays the same throughout the program, but the value or values contained in that
  2.3. Perl's Built-in Warnings Perl can be told to warn you when it sees something suspicious going on in your program. To run your program with warnings turned on, use the -w option on the command l
    2.5. Output with print It's generally a good idea to have your program produce some output; otherwise, someone may think it didn't do anything. The print( ) operator makes this possible. It takes
  2.6. The if Control Structure Once you can compare two values, you'll probably want your program to make decisions based upon that comparison. Like all similar languages, Perl has an if control stru
  2.7. Getting User Input At this point, you're probably wondering how to get a value from the keyboard into a Perl program. Here's the simplest way: use the line-input operator, <STDIN>.[] [] This is
  2.8. The chomp Operator The first time you read about the chomp operator, it seems overspecialized. It works on a variable, and the variable has to hold a string. If the string ends in a newline cha
  2.10. The undef Value What happens if you use a scalar variable before you give it a value? Nothing serious and definitely nothing fatal. Variables have the special undef value before they are first
  2.9. The while Control Structure Like most algorithmic programming languages, Perl has a number of looping structures.[] The while loop repeats a block of code as long as a condition is true: [] Eve
  2.12. Exercises See Appendix A for answers to the following exercises: [5] Write a program that computes the circumference of a circle with a radius of 12.5. Circumference is 2p times the radius (ap
  2.11. The defined Function One operator that can return undef is the line-input operator, <STDIN>. Normally, it returns a line of text. But if there is no more input, such as at end-of-file, it will
  3.2. Special Array Indices If you store in an array an element that is beyond the end of the array, the array is automatically extended as needed. There's no limit on its length as long as there's a
  3.1. Accessing Elements of an Array If you've used arrays in another language, you won't be surprised to find Perl provides a way to subscript an array to refer to an element by a numeric index. The
  3.4. List Assignment In much the same way as scalar values, list values may be assigned to variables: ($fred, $barney, $dino) = ("flintstone", "rubble", undef); All three variables in the list o
  3.3. List Literals An array (the way you represent a list value within your program) is a list of comma-separated values enclosed in parentheses. These values form the elements of the list: (1,