摘要: Vamie前辈的博客:http://www.cnblogs.com/vamei/archive/2012/07/03/2574436.html#!/usr/bin/pythonf = open('Summary.csv', 'r+');#"r" 只读, "r+" 读写#"w" 写入, "w+" 写读... 阅读全文
posted @ 2015-09-21 23:36 笑面浮屠 阅读(182) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/perl -wuse strict;#use autodie;#use File::HomeDir; #第三方模块,不管在什么操作系统上都能进入指定用户的主目录my $parentDir = 'F:\web\perl\perl program\littleCamp';my $p... 阅读全文
posted @ 2015-09-21 02:35 笑面浮屠 阅读(258) 评论(0) 推荐(0) 编辑
摘要: =pod第十七章 高级perl技巧切片: my (undef, $card_num, undef, undef, undef, $count) = split /:/; 定义undef的话,会默认忽略匹配的变量 更好的方法: 列表切片 my $mtime = (stat $some_file)... 阅读全文
posted @ 2015-09-21 02:11 笑面浮屠 阅读(271) 评论(0) 推荐(0) 编辑
摘要: =pod第十六章 进程管理身为程序员最棒的一面,就是能运行别人的程序,不必自己动手去写。在perl里有一句话叫 “办法不止一种”system函数: 在perl中,启动子进程最简单的方法是用system函数,例如从perl调用Unix的date命令,需要告诉system要运行的外部程序的名字: ... 阅读全文
posted @ 2015-09-21 02:08 笑面浮屠 阅读(261) 评论(0) 推荐(0) 编辑
摘要: =pod第十五章 智能匹配与given-when结构智能匹配操作符:~~ use 5.010001; say "I found Fred in the same" if $name ~~ /Fred/; 找出哈希表中是否包含“Fred” use 5.010001; say "I found a ke... 阅读全文
posted @ 2015-09-21 02:06 笑面浮屠 阅读(285) 评论(0) 推荐(0) 编辑
摘要: =pod第十四章 字符串与排序用index查找子字符串: my $where = index($big, $small); eg:my $stuff = "Howdy world"; my $where = index($stuff, "wor"); #$where = 6 index函数还能... 阅读全文
posted @ 2015-09-21 02:04 笑面浮屠 阅读(241) 评论(0) 推荐(0) 编辑
摘要: =pod第十三章 目录操作 在目录树中移动: 程序运行时会以自己的工作目录作为相对路径的起点,也就是说,当我们提及fred这个文件时,其实指的是"当前工作目录下的fred" chdir '/etc' or die "Cannot chdir to /etc: $!"; 如果掉... 阅读全文
posted @ 2015-09-21 02:01 笑面浮屠 阅读(321) 评论(0) 推荐(0) 编辑
摘要: =pod第十二章 文件测试 文件测试操作符: -e:判断文件是否存在 在创建新文件程序之前,应先检查指定的文件是否已经存在,以免意外覆盖重要的电子表格或是宝贵的生日档案。要达到此目的,我们可以用-e文件测试操作符来测试文件是否存在: die "Oops ! A fil... 阅读全文
posted @ 2015-09-21 01:58 笑面浮屠 阅读(134) 评论(0) 推荐(0) 编辑
摘要: =pod第十一章 perl模块寻找模块: cpan -a安装模块: perl Makefile.PL make install #如果没有权限安装在系统级目录,那就安装在个人目录 perl Makefile.PL INSTALL_BASE=/Users/fred/lib使用简易模块: my $nam... 阅读全文
posted @ 2015-09-21 01:54 笑面浮屠 阅读(231) 评论(0) 推荐(0) 编辑
摘要: =pod第十章 其他控制结构unless控制结构:和if相对 在条件为假时想要运行代码块,就用unless否则就用if: unless(judge){ } 伴随unless的else子句: unless(){ } else { } until控制结构: until($j > $i) { $j *... 阅读全文
posted @ 2015-09-21 01:51 笑面浮屠 阅读(267) 评论(0) 推荐(0) 编辑
摘要: =pod#第九章:用正则表达式处理文本用s///进行替换 s///查找替换功能 s/Barney/Fred/; #把Barney替换成Fred s/with (\w+)/against $1's team/; 例子: $_ = "green scaly dinosaur"; s/(\w+) (... 阅读全文
posted @ 2015-09-21 01:47 笑面浮屠 阅读(237) 评论(0) 推荐(0) 编辑
摘要: #用正则表达式进行匹配=pod m// = // = m%%,m||,m,m{},m(),匹配的时候根据需要写自己的定界符,像qw省略双引号定界符一样模式匹配修饰符: 跟在定界符后面的,//x,x就是模式匹配修饰符 i 忽略大小写 s 匹配任意字符 if(/Barney.*Fred/s){}#s... 阅读全文
posted @ 2015-09-21 01:44 笑面浮屠 阅读(301) 评论(0) 推荐(0) 编辑
摘要: =pod正则表达式(regular expression),在perl里面通常也叫做模式(pattern),是用来表示匹配或不匹配某个字符串的特征模板。 文件名通配与正则表达式是两个概念。grep指令: $grep 'flint.*stone' chapter*.txt #查看chaper*.txt... 阅读全文
posted @ 2015-09-21 01:40 笑面浮屠 阅读(159) 评论(0) 推荐(0) 编辑
摘要: =pod哈希 哈希表里只是一堆的键值对而已,而没有任何顺序,键可以是任意字符串,值也是 awk的哈希键值对增多的时候会逐渐变慢,而perl没有这个缺点 访问哈希元素: $hash{$some_key} foreach my $person (qw) { p... 阅读全文
posted @ 2015-09-21 01:33 笑面浮屠 阅读(281) 评论(0) 推荐(0) 编辑
摘要: =pod#第五章 输入与输出 while(defined($line = )) #defined (xxx) xxx为undef则为假,否则为真 { print "I saw $line"; }while() #while是一次读取一行,下次读取会忽略上一行,所以最好写while循环 { ... 阅读全文
posted @ 2015-09-21 01:29 笑面浮屠 阅读(547) 评论(0) 推荐(0) 编辑
摘要: 来自Vamie前辈博客:http://www.cnblogs.com/vamei/archive/2012/06/06/2537436.html#!/usr/bin/python#介绍一个新的类,词典 (dictionary)。与列表相似,词典也可以储存多个元素。#这种储存多个元素的对象称为容器(c... 阅读全文
posted @ 2015-09-21 01:12 笑面浮屠 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 来自Vamie前辈的博客:http://www.cnblogs.com/vamei/archive/2012/06/02/2532274.html#!/usr/bin/python#dir()用来查询一个类或者对象所有属性print (dir(list))#help()用来查询的说明文档print ... 阅读全文
posted @ 2015-09-21 00:40 笑面浮屠 阅读(203) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/python#dir()用来查询一个类或者对象所有属性print (dir(list))#help()用来查询的说明文档print ('================================================')print (help(list)) #列... 阅读全文
posted @ 2015-09-21 00:18 笑面浮屠 阅读(100) 评论(0) 推荐(0) 编辑