与Perl和Ruby __END__进行比较的相似语言功能 [英] Similar language features to compare with Perl and Ruby __END__

查看:94
本文介绍了与Perl和Ruby __END__进行比较的相似语言功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

Perl和Ruby具有__END____DATA__令牌,这些令牌允许将任意数据直接嵌入源代码文件中.

Perl and Ruby have the __END__ and __DATA__ tokens that allow embedding of arbitrary data directly inside a source code file.

尽管这种做法可能不适合在通用编程中使用,但对于执行常规任务的一次性"快速脚本来说却非常有用.

Although this practice may not be well-advised for general-purpose programming use, it is pretty useful for "one-off" quick scripts for routine tasks.

问题:

还有哪些其他编程语言支持相同或相似的功能,它们又是如何做到的?

What other programming languages support this same or similar feature, and how do they do it?

推荐答案

Perl支持__DATA__标记,您可以像访问常规文件句柄一样访问其内容.

Perl supports the __DATA__ marker, which you can access the contents of as though it were a regular file handle.

这篇关于与Perl和Ruby __END__进行比较的相似语言功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆