y***a 发帖数: 840 | 1 my $ooo = ($abb =~ m!\b(?:ld\w+p\b|m\w+sel\b|aaa|bbb|ccc)\w*!o);
看着不像查找m//
哪位给讲讲 | t****t 发帖数: 6806 | 2 m// can actually use arbitrary delimiter, as long as they match. in this
case, he apparently used "!" as delimiter.
【在 y***a 的大作中提到】 : my $ooo = ($abb =~ m!\b(?:ld\w+p\b|m\w+sel\b|aaa|bbb|ccc)\w*!o); : 看着不像查找m// : 哪位给讲讲
| t*****n 发帖数: 4908 | 3 天书一般的程序,特别是没注释的。。。
【在 y***a 的大作中提到】 : my $ooo = ($abb =~ m!\b(?:ld\w+p\b|m\w+sel\b|aaa|bbb|ccc)\w*!o); : 看着不像查找m// : 哪位给讲讲
| l*********s 发帖数: 5409 | 4 if this needs comment, you pretty much lose the advantage of using perl
because you are going to comment almost every line
:-).
【在 t*****n 的大作中提到】 : 天书一般的程序,特别是没注释的。。。
| t****t 发帖数: 6806 | 5 for perl RE, using /x modifier for complex RE is a good idea. You don't have
to use comments, just try to "group" with space.
【在 l*********s 的大作中提到】 : if this needs comment, you pretty much lose the advantage of using perl : because you are going to comment almost every line : :-).
| l*********s 发帖数: 5409 | 6 Part of the reasons for perl being hard to learn is there are tons of
shortcuts. No doubt it is a language designed for the experienced.
have
【在 t****t 的大作中提到】 : for perl RE, using /x modifier for complex RE is a good idea. You don't have : to use comments, just try to "group" with space.
| t****t 发帖数: 6806 | 7 本来就是自用的语言, 没指望拿perl写个大程序是不是? 可读性是差, 但是本来就不是
用来读的.
【在 l*********s 的大作中提到】 : Part of the reasons for perl being hard to learn is there are tons of : shortcuts. No doubt it is a language designed for the experienced. : : : have
| l*******G 发帖数: 1191 | 8
m! !o means to search the thing in between ! ! and compile once
[1] (?: ) Means to group but not catch the things found into
$1,$2,$3 etc internal expressions
[2] ld\w+p\b Means to match ld*p ended by a word boundary , where
* is any one or more char of a-z,A-Z,0-9 or _
[3] m\w+sel\b Means to match m*sel followed by a word boundary where
* is same as above,
\b means word boundary
[4] aaa, bbb, ccc are plain string of aaa, bbb, ccc
the whole thing tries to match contents in $abb with one of above [2]to [4]
followed by zero, one or more of any other word char of a-zA-Z0-9_
and then compile once, and then give the results to $ooo
The compile once modifier o means only evaluate the pattern once, to save
time.
http://perl.plover.com/Regex/article.html
http://www.perlmonks.org/?node_id=905041
【在 y***a 的大作中提到】 : my $ooo = ($abb =~ m!\b(?:ld\w+p\b|m\w+sel\b|aaa|bbb|ccc)\w*!o); : 看着不像查找m// : 哪位给讲讲
|
|