How can I use __DATA__ twice?

后端 未结 3 1272
耶瑟儿~
耶瑟儿~ 2020-12-25 12:09

How can I use __DATA__ twice?

#!/usr/local/bin/perl
use warnings;
use 5.012;

while (  ) {
    print;
}

while (  ) {
           


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-25 13:01

    You can use the Data::Handle module to do the tell()ing and seek()ing for you behind the scenes. (Though I believe if you have perl 5.10 or later you can dup the DATA file handle instead of sharing the original DATA file handle and seeking back and forth in it.)

提交回复
热议问题