in reply to Dynamic Memory allocation

if i declare array with my, they will get destroyed when the control comes out of the function in which the addition

No, it will not. Perl automatic memory handling takes care of these things.

You can also use the [] operator as ...

$g_User{user1} = [@l_UserDetails];
to create a copy of the array and get a reference to it.