in reply to Problem stripping directory listing
If you're getting more entries than you expect, then there are more entries in @filelist than you expect. Adding
print "$fle\n"; [download]