in reply to How to push and print at the same time?

push @folders, "$_"
should be
push @folders, $_

You are adding noise to your script to needlessly create a copy of the string.