in reply to Iterate trough a series of folders

You might want to use the glob function, which simplifies significantly what you are trying to do: it preserves the path of the files and removes the . and .. pseudo directories.
my @dirs = grep {-d} glob ("$path/*");