我在哪里可以找到有关 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 filehandleFOOBAR::DATA
, whereFOOBAR
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/