The addFile method allows you to add a second parameter with a new name for the file, that is what it will be called inside the zip file. You can use File::Basename to get just the filename from $memberName.
foreach my $memberName (map { glob } $indir)
{
if (-d $memberName )
{
if($zip->addFile( $memberName ) != AZ_OK){
#or sendalert();
$message = "Can't add file $memberName\n";}
}
}
This is using -d $memberName to test for directories. The addFile method is for adding a file, there are other methods for adding directories. I am surprised to see this since you said all works well in this script. Also, I'm surprised to see the glob statement by itself.