後續代碼會吃@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