摘要: 原文网址:http://hi.baidu.com/rdzwx/blog/item/6b52c9c4bdf70c179d163d81.htmlperl 半角 全角 转换2010-05-18 10:33# 全角字符第一字节 = 163(0xA3), 第二字节为对应半角字符 + 128# 全角中文第一字节 > 163my $str = ‘019AaBbYyZz\",.?<>{}[]*&^%#@!~()+-|:;';print "$str\n";$str =~ s/\x{A3}(.)/chr(ord($1) - 128)/eg;print "$str\n&q 阅读全文
posted @ 2012-01-31 16:19 xiaodongrush 阅读(1800) 评论(2) 推荐(1) 编辑
摘要: 1. 任务 为了实现一些机械分词算法,准备使用“国家语委语料库”的分词词表,在线下载到得词表文件是一个Excel文件。本文的任务就是使用Perl从该Execl文件中提取所有的词语。词表文件格式如下: 需要的词语的位置在从第8行开始的,第B列的所有单元格。一共有14629个词语。(PS:语料库的分词词表包含8万多个词语,但是在线下载到是出现次数在50次以上的词语,只有这1万多)。2. 使用什么模块 通过阅读一些博文发现,PERL的Spreadsheet::ParseExcel模块支持Excel的读操作。3. 如何下载模块(windows xp上的草莓PERL)在命令行下输入:cpan Sprea 阅读全文
posted @ 2012-01-30 16:07 xiaodongrush 阅读(21749) 评论(1) 推荐(3) 编辑
摘要: 原文网址:http://hi.baidu.com/0soul/blog/item/91098701f5051880e850cd4b.html原文:http://www.perl.com/pub/a/2002/08/20/perlandlwp.html版权信息有点多,其它的我写在最后。我觉得这个Perl的LWP文档挺不错的,所以就转过来,方便随时查阅,呵呵。下面是转载内容:************************************************************************************The Fuck Cutline************* 阅读全文
posted @ 2012-01-20 16:45 xiaodongrush 阅读(2507) 评论(1) 推荐(1) 编辑
摘要: 原文网址:http://hi.baidu.com/jackywdx/blog/item/35bb33daedb414dfb7fd4867.html一 LWP::Simple 功能1. 如何在Perl中使用该模块?use LWP::Simple;2. 如何获取一个页面内容?my $content = get(’http://www.yahoo.com.cn’);get函数把从www.yahoo.com.cn上获取得页面内容全部赋给$content这个变量,如果获取失败将返回一个undef的值。3. 如何获取头(Header)?my (b, d, $e) = header(’http://www. 阅读全文
posted @ 2012-01-20 16:43 xiaodongrush 阅读(783) 评论(1) 推荐(0) 编辑
摘要: 1. 题目2. 代码与输出1#-----------------------------------------------------------#2#Source:LearningPerl,chapter10,exercise-13#Date:2012-01-204#Author:xiaodongrush5#-----------------------------------------------------------#6use5.010;7$secret_num=int(1+rand100);8while(<STDIN>){9chomp;10if(/^[0-9]+$/) 阅读全文
posted @ 2012-01-20 12:37 xiaodongrush 阅读(354) 评论(0) 推荐(0) 编辑
摘要: 1. 题目 2. 代码与输出 1#-----------------------------------------------------------#2#Source:LearningPerl,chapter9,exercise-13#Date:2012-01-194#Author:xiaodongrush5#-----------------------------------------------------------#6use5.010;7@array=qw{8fredfredfred9fredfredbarney10barneyfredfred11barneybarneyba. 阅读全文
posted @ 2012-01-19 13:52 xiaodongrush 阅读(767) 评论(0) 推荐(0) 编辑
摘要: 1. 题目 2. 代码与输出1#-----------------------------------------------------------#2#Source:LearningPerl,chapter8,exercise-13#Date:2012-01-184#Author:xiaodongrush5#-----------------------------------------------------------#6use5.010;7while(<>){8chomp;9if($_=~m|match|){10say"<$`><$& 阅读全文
posted @ 2012-01-18 10:33 xiaodongrush 阅读(592) 评论(0) 推荐(0) 编辑
摘要: 1. 题目 原始题目阐述有些问题,这里说明一下。第1题:匹配包含fred的行。第2题:匹配包含fred或者Fred的行。第3题:匹配包含点号的行。第4题:匹配大写字母开头的行。第5题:包含连续两个相同的非空格字符的行,比如AA,aa,¥¥,等。第6题:匹配既有wilma也有fred的行。2. 代码与输出第1题:匹配包含fred的行。 1#-----------------------------------------------------------#2#Source:LearningPerl,chapter7,exercise-13#Date:2012-01-174#Author:xi. 阅读全文
posted @ 2012-01-17 11:16 xiaodongrush 阅读(519) 评论(2) 推荐(0) 编辑
摘要: 1. 题目2. 代码与输出 ch6-family-name.pl1#-----------------------------------------------------------#2#Source:LearningPerl,chapter6,exercise-13#Date:2012-01-164#Author:xiaodongrush5#-----------------------------------------------------------#6use5.010;7%family_name_hash=(8"fred"=>"flintst 阅读全文
posted @ 2012-01-16 11:16 xiaodongrush 阅读(379) 评论(0) 推荐(0) 编辑
摘要: 1. 习题 2. 代码与输出cat_reverse.pl1#-----------------------------------------------------------#2#Source:LearningPerl,chapter5,exercise-13#Date:2012-01-154#Author:xiaodongrush5#-----------------------------------------------------------#6use5.010;7while(<>){chomp;unshift@array,$_;}8foreach(@array){s 阅读全文
posted @ 2012-01-15 12:27 xiaodongrush 阅读(510) 评论(0) 推荐(0) 编辑