B
Bryan
If I have a hash reference, and want to assign a reference to a snapshot
of a changing array, what is the correct syntax?
$hash_ref->{'key'} = @array;
Obviously doesn't work
$hash_ref->{'key'} = \@array;
Doesn't work since my array is changed then reused for different keys,
the values get hosed.
my @tmp_array = @array;
$hash_ref->{'key'} = \@tmp_array;
Works as I want, but now I have an extra line of code.
Is that really necessary? Seems a bit clumsy to have to make a local
copy explicitly like that...
Thanks,
B
of a changing array, what is the correct syntax?
$hash_ref->{'key'} = @array;
Obviously doesn't work
$hash_ref->{'key'} = \@array;
Doesn't work since my array is changed then reused for different keys,
the values get hosed.
my @tmp_array = @array;
$hash_ref->{'key'} = \@tmp_array;
Works as I want, but now I have an extra line of code.
Is that really necessary? Seems a bit clumsy to have to make a local
copy explicitly like that...
Thanks,
B