|Come for the quick hacks, stay for the epiphanies.
Are you sure you only attempt to remove empty directories? To me it seems you are trying to delete all entries in /ep005/egate/client/iq/, regardless whether they are files, non-empty directories or empty directories.
But then, I only looked at your program briefly. It's just a wad of undocumented code, without explaining what it is supposed to do. The error message is not a Perl error.