gpt4 book ai didi

perl - perl 中的 语法

转载 作者:行者123 更新时间:2023-12-03 11:37:22 25 4
gpt4 key购买 nike

我在哪里可以找到有关 perl 中以下语法的更多信息?
<DATA>之间的联系和 __DATA__不清楚。

while (my $date_string = <DATA>) {
chomp($date_string);
next if not length $date_string;
print "$date_string ist Unixtime ",
$lang_date->str2time($date_string),
" und ",
$lang_date->time2str( '%d.%m.%Y %T (%Z)',$lang_date->str2time($date_string) ),
"\n";
}

__DATA__
1.3.1999
1 Marz 1999
1. Marz 1999
1/3/1999

最佳答案

报价the doc :

The __DATA__ token tells the perl compiler that the perl code for compilation is finished.

Everything after the __DATA__ token is available for reading via the filehandle FOOBAR::DATA, where FOOBAR is the name of the current package when the __DATA__ token is reached.

This works just the same as __END__ does in package 'main', but for other modules data after __END__ is not automatically retrievable, whereas data after __DATA__ is.



只能添加到使用 __DATA__部分非常方便地说明 Perl 中一些与文件读取相关的概念。它基本上是一个附加到代码的文件,并且可以通过 <DATA> 轻松访问该文件的内容。 .这就是为什么它在 SO 上很受欢迎的原因。 )

关于perl - perl 中的 <DATA> 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13463509/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com