Thank you guys.
There is another scenario, if the Perl file is accessed through web(apache http server is started), that is to use http://localhost/test/test.pl, problem will raise.
In each loop,the statement
will get '', instead of filename.However, if run the file as "perl -w test.pl" in linux, everything ok.
Could you please gimme some advice on this issue? Thank you.