Perl:基本问题,函数功能
这个函数有什么作用?
sub MyDigit {
return <<END;
0030\t0039
END
}
What does this function do?
sub MyDigit {
return <<END;
0030\t0039
END
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这称为"here-document",用于分解字符串多行作为串联或列表操作的替代方法:
您可以在手册中阅读有关此处文档的更多信息:请参阅 perldoc perlop。
That's called a "here-document", and is used for breaking strings up over multiple lines as an alternative to concatenation or list operations:
You can read more about here-documents in the manual: see perldoc perlop.
你们都错过了重点!
它使用正则表达式定义一个用户定义的属性,供在
\p{MyDigit}
和\P{MyDigit}
中使用。就像这样:
或者,您可以根据现有属性名称来定义它:
您还可以使用“C<->”进行集合减法前缀。假设你只
想要实际的字符,而不仅仅是字符的块范围。
您可以像这样清除所有未定义的字符集:
您还可以使用“C”前缀从补充字符集开始:
我想我一定是对的,因为我说的是excamelis。 :)
You’ve all missed the point!
It’s defining a user-defined property for use in
\p{MyDigit}
and\P{MyDigit}
using regular expressions.It’s like these:
Alternatively, you could define it in terms of existing property names:
You can also do set subtraction using a "C<->" prefix. Suppose you only
wanted the actual characters, not just the block ranges of characters.
You could weed out all the undefined ones like this:
You can also start with a complemented character set using the "C" prefix:
I figure I must be right, since I’m speaking ex camelis. :)
它使用名为 此处文档 的内容来返回字符串“0030\t0039”
It uses something called a Here Document to return a string "0030\t0039"
它返回字符串
"0030\t0039\n"
(\t
是制表符,\n
是要添加的换行符,因为该行以换行符结尾(显然))。是所谓的heredoc,一种方便地编写多行字符串的方法(尽管这里只使用一行)。
It returns the string
"0030\t0039\n"
(\t
being a tab and\n
a newline that is being added because the line ends in a newline (obviously)).Is a so-called heredoc, a way to conveniently write multi-line strings (though here it is used with only one line).
您可以通过尝试一个简单的实验来帮助自己:
输出:
现在,在您的情况下,
END
没有排列在行的开头,因此您应该已经收到消息:You can help yourself by trying a simple experiment:
Output:
Now, in your case, the
END
is not lined up at the beginning of the line, so you should have gotten the message: