in reply to Problem stripping directory listing
All the other Perl changes suggested are good ones but the core of your problem is the find change suggested by zengargoyle. Without a -depth argument to limit the find you're actually getting more directories than you assumed. You're actually probably seeing the following (all directories):
/home/sites/$arg1/users/XY/ /home/sites/$arg1/users/YZ/ /home/sites/$arg1/users/YZ/bbb/ /home/sites/$arg1/users/BD/ /home/sites/$arg1/users/BD/ss/ /home/sites/$arg1/users/GD/ /home/sites/$arg1/users/GD/gg/ /home/sites/$arg1/users/ZX/
|
|---|