有种用法__DATA__是怎么用来着

有种用法__DATA__是怎么用来着

我记得有种方法把数据写在文件中
用__DATA__分割的

谁记得,提示下,要用
这个吗:

[Copy to clipboard] [ - ]
CODE:
Steps to follow:
1) At the end of the code use __DATA__ marker and copy paste or write the contents of the file you wish to test exactly from the next line of _DATA_.
2) Use while (){ -- your code here -- }.

#!/usr/bin/perl
use strict;
use warnings;

while () {
chomp $_;
print "Found" if $_ =~ /(t\w+)/;
print $1;
}
__DATA__
hello there how r u

Output of the above program will be “there”.

落叶季节,思念季节
你运行没,我这里运行是死循环啊
while (<DATA>) {

被吃了?

#!/usr/bin/perl
use strict;
use warnings;

while (<DATA>) {
chomp $_;
print "Found" if  /(t\w+)/;
print $1;
}
__DATA__
hello there how r u



#楼上的少了<DATA>

哦,对了,不错
对了, 得要 while (<DATA>

__DATA__还没好好研究过
落叶季节,思念季节
测试方便多了
又学了一招, 越来越喜欢perl了