Choroba i modified your code for my requirements and now %group hash has 40 keys, and __DATA__ has 345 lines.
The problem is that the code hangs and gets killed after sometime without any output. CPU usage going to 100%,system hang. Whereas if I reduce the __DATA__ lines to 300 lines only, then it runs . Why is it so. My system has 64Gigs ram, and hexacore.