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
热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短