这两个 Perl 片段有什么区别? [英] What's the difference between these two Perl snippets?
本文介绍了这两个 Perl 片段有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
print <<EOF
stuff
EOF
;
print <<EOF;
stuff
EOF
你为什么要使用一个?
推荐答案
这两个示例在行为上等同于同一件事,但请考虑在打印该块后是否还想做其他事情:
Those two examples amount to the same thing behaviourally, but consider if you wanted to do something else after printing that block:
print <<EOF
stuff
EOF
. "more text here";
...或者您可能需要测试操作的结果:
...or maybe you need to test the result of the operation:
print $unstable_filehandle <<EOF
stuff
EOF
or warn "That filehandle finally disappeared: $!";
这些示例是人为设计的,但您可以看到有时灵活处理文本块后面的代码会很有用.
These examples are contrived, but you can see how sometimes it can be useful to be flexible about what code comes after the block of text.
这篇关于这两个 Perl 片段有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文