Perl中的“此处”文档
您可以非常舒适地存储或打印多行文本。即使您可以在“此处”文档中使用变量。下面是一个简单的语法,请仔细检查<<和标识符之间是否没有空格。
标识符可以是一个简单的字词,也可以是一些带引号的文本,例如下面我们使用的EOF。如果用引号引起来,则使用的引号类型将决定此处文档中文本的处理方式,就像常规引号一样。未加引号的标识符的作用类似于双引号。
示例
#!/usr/bin/perl $a = 10; $var = <<"EOF"; This is the syntax for here document and it will continue until it encounters a EOF in the first line. This is case of double quote so variable value will be interpolated. For example value of a = $a EOF print "$var\n"; $var = <<'EOF'; This is case of single quote so variable value will be interpolated. For example value of a = $a EOF print "$var\n";
输出结果
这将产生以下结果-
This is the syntax for here document and it will continue until it encounters a EOF in the first line. This is case of double quote so variable value will be interpolated. For example value of a = 10 This is case of single quote so variable value will be interpolated. For example value of a = $a
热门推荐
1 训练狗狗基础
2 怎么训练狗狗笑
3 怎么训练狗狗卧下
4 上海狗狗训练基地
5 训练狗狗排便
6 狗狗基础训练
8 如何训练狗狗装死
9 狗狗站姿训练
10 狗狗训练用品
11 训练狗狗吧
12 狗狗要怎么训练
13 怎么训练狗狗玩球
14 训练狗狗唤回
15 狗狗训练躺下
16 狗狗训练指令
17 狗狗的训练技巧
18 狗狗不好训练