I saw a very strange piece of code in my Perl script used in the project, this is something like this:
$ arrayRef = [A = & gt; {AA = & gt; 11, AAA = & gt; 111}, b = & gt; {BB = & gt; 11, BBB = & gt; 111},]; IMO, it tries to create an anonymous array from a hash table. I try to print the array element and here I get it:
foreach (@ $ arrayRef) {print; Print "\ n"; } AHSH (0x1e60220) BHSH (0x1e71bd0)
which means that it considers every element (key and value) as a separate element in the unknown array in the hash table. Although I am really confused why they want to save a hash in an array. The only benefit for me is to save some memory if the hash table is really big enough is it a useless used Pearl trick?
Thank you!
It tries to create an anonymous array from a hash table
No, it creates an unknown array from the four-element list .
A => {AA = & gt; 11, AAA = & gt; 111}, b = & gt; {BB = & gt; 11, BBB = & gt; 111}
The exact same is
'a', {aA = & gt; 11, AAA = & gt; 111}, 'B', BB = & gt; 11, BBB = & gt;
= & gt; Using indicates some kind of relationship, so I think they can use it
{A => {AA = & gt; 11, AAA = & gt; 111}, b = & gt; {BB = & gt; 11, BBB = & gt; 111}}
or
[[A = & gt; {AA = & gt; 11, AAA = & gt; 111}], [b = & gt; {BB = & gt; 11, BBB = & gt; 111}]
Or any of the other million other data structures, but it is a way to find out why any of the choices you have given have been selected.
No comments:
Post a Comment