What is the meaning of these lines (% S) = @C_fields ;?

I have one general question in Perl. What the bottom line means

keys(%S) =@C _fields; 
+5
source share
1 answer

keys(%S) =@C _fields; identical to keys(%S) = scalar @C_fields;

and perldoc -f keys

Used as an lvalue, keys allow you to increase the number of hash codes allocated for a given hash . This can increase efficiency if you know that the hash will become big. (This is similar to pre-expanding the array by assigning a larger number to the $ # array.) If you say

keys %hash = 200;

then% hash will have at least 200 buckets allocated - in fact 256 of them, since it is rounded to the next capacity of two.

So, hash %S will get the number of buckets whose size is not less than @C_fields .

+8
source

Source: https://habr.com/ru/post/1212796/


All Articles