Thanks for your reply.
The issue is , code isn't looping through each group and member from the list
As you mentioned, the looping inside looping is confused, I guess and need more functions but don't know what it is.
I'm just learning to write in Perl so definitely need more help to understand.