2012年4月20日

问号在正则表达式里的四种用途

摘要: 原文问号,需要转义有无量词非贪婪修饰符不捕获前缀 阅读全文

posted @ 2012-04-20 17:23 perlman 阅读(746) 评论(0) 推荐(0) 编辑

use re 'debug' 可以查看正则表达式的匹配过程。

摘要: use strict;use warnings;use re 'debug';sub test { my $str = "123456789"; print join(":", split /(?<=...)/, $str);}test(); 阅读全文

posted @ 2012-04-20 12:56 perlman 阅读(461) 评论(0) 推荐(0) 编辑

用{}修饰变量名

摘要: 用{}修饰变量名,可以防止 _ 被解释为变量名的一部分。sub test { my $head = "abc"; my $tail = "def"; my $full = "${head}_${tail}"; print $full, "\n";}直接写成下面这样,在strict模式下是无法通过的。my $full = "$head_$tail"; 阅读全文

posted @ 2012-04-20 12:44 perlman 阅读(476) 评论(1) 推荐(0) 编辑

导航