in reply to Re^2: Create zip files for each sub-directory under a main directory
in thread Create zip files for each sub-directory under a main directory

You should check what's actually in @files. Not just for filenames but also whether they exist and (perhaps also) are of the expected size: see the built-in "File Test Operators".

I suspect you probably want to glob "$dir/*.eap". With your posted code, you're only looking for "*.eap" in the current directory. Look for other places where you may be referencing the current directory instead of $dir.

Two other minor points: (1) I wouldn't declare @files globally; (2) foreach and for are synonymous.

Putting all those points together, instead of:

my @files; foreach my $dir (@dirs) { @files = glob "*.eap"; ...

I probably would have written something closer to:

for my $dir (@dirs) { my @files = glob "$dir/*.eap"; ...

For the inner loop, $_ is the default. Adding it the way you have (foreach $_ (@files) { ...) makes me, and quite possibly others, wonder if you perhaps had some other intention, e.g. a lexical 'my $_' (which should be avoided anyway - see below). One of these two forms would be more normal (and won't raise eyebrows):

for (@files) { ...
for my $file (@files) { ...

[Use foreach, instead of for, if you want to. It's really just extra (and unnecessary) typing. As stated earlier, the two are synonymous.]

Using a consistent style of indentation will make your code easier to read and less prone to errors. The choice of coding style is often a very personal one: choose whatever you want. See perlstyle if you want some tips on this.

Finally, and only because I mentioned it passing above, lexical $_ should be avoided. Here's its history:

— Ken