Perl language punter

advertisements

Can You please confirm me the how the below command will work or purpose of this type of statement.

           $layermap{@myline0[1]}=$myline[1];

Thanks & Regards Madhvi


Let's dissect $layermap{@myline0[1]}=$myline[1];

%layermap is a hash (an unordered map, or an associative array, or a dictionary, if you're coming from other languages with different nomenclatures). $layermap{KEY} is one element of the hash. This element can have a value.

@myline0 and @myline are arrays. $myline0[1] and $myline[1] are each the second element of their respective arrays. These elements can hold a value.

@myline0[1] is a sloppy way of writing $myline0[1] (it works, because it's a single-element slice).

So your line of code assigns a value to the element in the %layermap hash with a key derived from the value of $myline0[1]. The value assigned is the value held in the $myline[1] of the array @myline.