needperlhelp has asked for the wisdom of the Perl Monks concerning the following question:
I have an global associative array %g_User; with keys as userids
for each user i want to dynamically create an array and attach its refrence to the value of the associative array as shown below
$g_User{'user1'} = \@l_UserDetails;
but i face the following problem;
> if dont declare the array @l_UserDetails, the variable is global and all users refer to the same array
> if i delare array with my / local , they will get destroyed when the control comes out of the function in which the addition happens
do we have something simillar to new / malloc in perl
or
is there a simpler way to handle this situation in perl
please help
for each user i want to dynamically create an array and attach its refrence to the value of the associative array as shown below
$g_User{'user1'} = \@l_UserDetails;
but i face the following problem;
> if dont declare the array @l_UserDetails, the variable is global and all users refer to the same array
> if i delare array with my / local , they will get destroyed when the control comes out of the function in which the addition happens
do we have something simillar to new / malloc in perl
or
is there a simpler way to handle this situation in perl
please help
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Dynamic Memory allocation
by salva (Canon) on Dec 15, 2005 at 10:22 UTC | |
Re: Dynamic Memory allocation
by tirwhan (Abbot) on Dec 15, 2005 at 10:24 UTC | |
Re: Dynamic Memory allocation
by Corion (Patriarch) on Dec 15, 2005 at 10:25 UTC | |
Re: Dynamic Memory allocation
by Tomte (Priest) on Dec 15, 2005 at 10:22 UTC | |
Re: Dynamic Memory allocation
by Moron (Curate) on Dec 15, 2005 at 14:10 UTC | |
Re: Dynamic Memory allocation
by blazar (Canon) on Dec 15, 2005 at 14:21 UTC |
Back to
Seekers of Perl Wisdom