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

push @folders, "$_" and print $FOLDERS "$_\n"
without relying on the value from push is
push(@folders, "$_"), print $FOLDERS "$_\n"