加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl中的语法

发布时间:2020-12-15 21:14:14 所属栏目:大数据 来源:网络整理
导读:在哪里可以找到有关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
在哪里可以找到有关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>容易地访问该文件的内容.这就是为什么它在这里很受欢迎. )

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读