后续代码会吃@populations的perl的foreach吃所有的数组内容
@populations=("EUR","AFR","ASN","AMR");
print @populations,"\n"; #will show EURAFRASNAMR
foreach (@populations)
{
$filepath="tmp.txt"; #whatever text file you like
open(FILE,"<$filepath");
while(<FILE>)
{
}
}
print @populations,"\n"; #will print nothing
的内容,如果改变
foreach $i (@populations)
则数组将不会被吃掉。如果标记while循环,则数组不会被吃掉。
我不是perl大师,但有几年的经验。
谁能告诉我为什么?它是一个Perl的错误?
谢谢你们! – user1143669 2013-02-15 22:10:22