亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫
12下一頁
最近訪問板塊 發(fā)新帖
查看: 6059 | 回復(fù): 16
打印 上一主題 下一主題

__END__和__DATA__ [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2008-12-27 21:28 |只看該作者 |倒序?yàn)g覽
__END__ 表示腳本的末尾位置,其后內(nèi)容將被忽略
__DATA__ 特殊文件句柄

看到perl by example里一個(gè)示例說可以用_END_代替_DATA_,實(shí)驗(yàn)一下確實(shí)如此但是不明白為什么?

比如
----------------------------------------------------
...
print <DATA>;

__DATA__
The quick brown fox jumps over the lazy dog
----------------------------------------------------


----------------------------------------------------
...
print <DATA>;

__END__
The quick brown fox jumps over the lazy dog
----------------------------------------------------

都是輸出:
The quick brown fox jumps over the lazy dog

[ 本帖最后由 wertyu 于 2008-12-28 12:19 編輯 ]

論壇徽章:
1
辰龍
日期:2014-05-15 19:37:15
2 [報(bào)告]
發(fā)表于 2008-12-27 23:35 |只看該作者
這本破書的例子有問題。。。。這個(gè)地方我也花了很多時(shí)間來看看 ,--DATA-- 這個(gè)只是指輸入的文件句柄之類的意思,不是實(shí)體的詞....換成_--AAAA--也行,只是指這種類型來輸入的數(shù)據(jù)

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2008-12-27 23:37 |只看該作者
原帖由 iakuf 于 2008-12-27 23:35 發(fā)表
這本破書的例子有問題。。。。這個(gè)地方我也花了很多時(shí)間來看看 ,--DATA-- 這個(gè)只是指輸入的文件句柄之類的意思,不是實(shí)體的詞....換成_--AAAA--也行,只是指這種類型來輸入的數(shù)據(jù)


我倒!

論壇徽章:
95
程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-09-05 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-09-17 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-09-18 06:20:002015亞冠之阿爾艾因
日期:2015-09-18 10:35:08月度論壇發(fā)貼之星
日期:2015-09-30 22:25:002015亞冠之阿爾沙巴布
日期:2015-10-03 08:57:39程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-10-05 06:20:00每日論壇發(fā)貼之星
日期:2015-10-05 06:20:002015年亞冠紀(jì)念徽章
日期:2015-10-06 10:06:482015亞冠之塔什干棉農(nóng)
日期:2015-10-19 19:43:35程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-10-21 06:20:00每日論壇發(fā)貼之星
日期:2015-09-14 06:20:00
4 [報(bào)告]
發(fā)表于 2008-12-28 10:24 |只看該作者
原帖由 iakuf 于 2008-12-27 23:35 發(fā)表
這本破書的例子有問題。。。。這個(gè)地方我也花了很多時(shí)間來看看 ,--DATA-- 這個(gè)只是指輸入的文件句柄之類的意思,不是實(shí)體的詞....換成_--AAAA--也行,只是指這種類型來輸入的數(shù)據(jù)

是 __DATA__,不是 --DATA--

論壇徽章:
1
2015年辭舊歲徽章
日期:2015-03-03 16:54:15
5 [報(bào)告]
發(fā)表于 2008-12-28 10:30 |只看該作者
原帖由 MMMIX 于 2008-12-28 10:24 發(fā)表

是 __DATA__,不是 --DATA--

我一直認(rèn)為,這些細(xì)微之處,反應(yīng)了一個(gè)人是否適合搞編程。

我相信那位朋友一定清楚自己想要表達(dá)的其實(shí)就是 __DATA__,
只不過:
1,鍵盤不好
or
2,懶得按 shift
or
3,不小心打錯(cuò)了,懶得糾正
罷了。

論壇徽章:
0
6 [報(bào)告]
發(fā)表于 2008-12-28 11:41 |只看該作者
原帖由 flw 于 2008-12-28 10:30 發(fā)表

我一直認(rèn)為,這些細(xì)微之處,反應(yīng)了一個(gè)人是否適合搞編程。

我相信那位朋友一定清楚自己想要表達(dá)的其實(shí)就是 __DATA__,
只不過:
1,鍵盤不好
or
2,懶得按 shift
or
3,不小心打錯(cuò)了,懶得糾正
罷了。

深表贊同。

有些人知道code標(biāo)簽懶得用、也懶的縮進(jìn)和排版,像下面這樣粘上一堆亂糟糟的代碼就跑來問人:
#include <stdio.h>

int main() {
      int i;
   if (i < 1)
  printf("hello\n");
    else
     printf("world\n");
  }

[ 本帖最后由 pugs 于 2008-12-28 11:42 編輯 ]

論壇徽章:
0
7 [報(bào)告]
發(fā)表于 2008-12-28 12:24 |只看該作者
原帖由 iakuf 于 2008-12-27 23:35 發(fā)表
這本破書的例子有問題。。。。這個(gè)地方我也花了很多時(shí)間來看看 ,--DATA-- 這個(gè)只是指輸入的文件句柄之類的意思,不是實(shí)體的詞....換成_--AAAA--也行,只是指這種類型來輸入的數(shù)據(jù)



剛剛實(shí)驗(yàn)了下,好像事實(shí)和這位兄弟說的有些出入啊,不知道是不是我哪里理解錯(cuò)了

#!/usr/bin/perl

use strict;
use warnings;

while (<DATA>) {
        chomp;
        print "Found:\n
$`<$&>$'\n" if /\bfox\b/;
}

__DATA__
The quick brown fox jumps over the lazy dog




把__DATA__換成__END__倒是一樣的結(jié)果:
Found:
The quick brown <fox> jumps over the lazy dog

但是換成別的任意值就不對了。 這個(gè)__DATA__和__END__究竟什么關(guān)系啊?

[ 本帖最后由 wertyu 于 2008-12-28 13:01 編輯 ]

論壇徽章:
1
2015年辭舊歲徽章
日期:2015-03-03 16:54:15
8 [報(bào)告]
發(fā)表于 2008-12-28 13:03 |只看該作者
一定要學(xué)會(huì)查文檔。
  1.     The two control characters ^D and ^Z, and the tokens __END__ and
  2.     __DATA__ may be used to indicate the logical end of the script before
  3.     the actual end of file. Any following text is ignored.

  4.     Text after __DATA__ but may be read via the filehandle "PACKNAME::DATA",
  5.     where "PACKNAME" is the package that was current when the __DATA__ token
  6.     was encountered. The filehandle is left open pointing to the contents
  7.     after __DATA__. It is the program's responsibility to "close DATA" when
  8.     it is done reading from it. For compatibility with older scripts written
  9.     before __DATA__ was introduced, __END__ behaves like __DATA__ in the
  10.     toplevel script (but not in files loaded with "require" or "do") and
  11.     leaves the remaining contents of the file accessible via "main::DATA".

  12.     See SelfLoader for more description of __DATA__, and an example of its
  13.     use. Note that you cannot read from the DATA filehandle in a BEGIN
  14.     block: the BEGIN block is executed as soon as it is seen (during
  15.     compilation), at which point the corresponding __DATA__ (or __END__)
  16.     token has not yet been seen.
復(fù)制代碼

論壇徽章:
0
9 [報(bào)告]
發(fā)表于 2008-12-28 13:08 |只看該作者
有點(diǎn)弄明白了,__DATA__和__END__同樣都是表示腳本結(jié)束,不過__END__只能在main package中使用,而__DATA__在任意package里都可以使用。

__DATA__會(huì)打開文件句柄DATA, 看樣子__END__也會(huì)打開DATA文件句柄。

如果有理解錯(cuò)的地方麻煩指點(diǎn)。

論壇徽章:
0
10 [報(bào)告]
發(fā)表于 2008-12-28 13:10 |只看該作者

  1. perldoc perldata
復(fù)制代碼

看special literals一節(jié)

  1. The two control characters ^D and ^Z, and the tokens __END__ and __DATA__ may be used to indicate the logical end of the script before the actual end of file. Any following text is ignored.

  2. Text after __DATA__ but may be read via the filehandle PACKNAME::DATA , where PACKNAME is the package that was current when the __DATA__ token was encountered. The filehandle is left open pointing to the contents after __DATA__. It is the program's responsibility to close DATA when it is done reading from it. For compatibility with older scripts written before __DATA__ was introduced, __END__ behaves like __DATA__ in the top level script (but not in files loaded with require or do) and leaves the remaining contents of the file accessible via main::DATA .
復(fù)制代碼
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP