in reply to Scripts work when run individually but not when run as one compiled script

I wouldn't phrase it as harsh as Laurent_R did, but this:

Indentation is not about making the script pretty, it is about making the intent of the programmer clear.
is definitely true.

After applying perltidy, I don't see much suspicious (except perhaps that you push the file names to an array, and later get them from glob).
Since you already applied the first bullet point of Basic debugging checklist, you should go on there.
  • Comment on Re: Scripts work when run individually but not when run as one compiled script
  • Download Code