in reply to Grouping files before zipping!

splice(@files, $next_index, 0)

Wouldn't that always return an empty list and not modify the array at all?