in reply to Problem stripping directory listing

The problem i am facing is that i am getting multiple entries if the username folder contains more than one folder. How can i solve this problem?

If you're getting more entries than you expect, then there are more entries in @filelist than you expect. Adding

print "$fle\n";
at the top of your loop might tell you why.