Is it possible to assign the reference of an array as the value in the key : value
pair of a hash table in perl?
相关问题
- Why does const allow implicit conversion of refere
- facebook error invalid key hash for some devices
- How to get the maximum of more than 2 numbers in V
- Faster loop: foreach vs some (performance of jsper
- $ENV{$variable} in perl
相关文章
- Numpy matrix of coordinates
- PHP: Can an array have an array as a key in a key-
- Bcrypt vs Hash in laravel
- Running a perl script on windows without extension
- Accessing an array element when returning from a f
- How can I convert a PHP function's parameter l
- How to make a custom list deserializer in Gson?
- Which is faster, pointer access or reference acces
Yes. See http://perlmonks.org/?node=References+quick+reference for some basic rules for accessing such data structures, but to create it, just do one of these:
Yes it is. Create a reference to the array by using backslash:
Note that this will link to the actual array, so if you perform a change such as:
That will also mean that
$hash{key}[0]
is set to"foo"
.If that is not what you want, you may copy the values by using an anonymous array reference
[ ... ]
:Moreover, you don't have to go through the array in order to do this. You can simply assign directly:
Read more about making references in perldoc perlref