I have an existing array that I want to add as a value to the hash. I know that you can use arrays as values, but you cannot assign an existing one. I basically want to go:
$hash{fieldName} = @myArray;
Only this obviously does not work! Help rate!
You can only store scalar values in hashes / arrays. You need to use:
$hash{fieldName} = \@myArray;
to save it, and:
my @myOtherArray = @{$hash{fieldName}};
to return it. It works with scalar requirement using array reference.
And since no one mentioned this, your code looked like this:
,
$hash{fieldName} (scalar @myarray)
$hash{fieldName}
scalar @myarray
, , , \@myArray, [ @myArray ] ( ) dclone ( ).
\@myArray
[ @myArray ]
$hash{fieldName} = \@myArray, $hash{fieldName}->[2] @myArray. @myArray , .
$hash{fieldName} = \@myArray
$hash{fieldName}->[2]
@myArray
, '\',
:
@{$hash{fieldName}}
Source: https://habr.com/ru/post/1719167/More articles:Can I revert to using ReSharper? - c #svn cannot connect to host 'localhost' - svnКак аутентифицировать пользователя веб-сайта через iphone - authenticationIs Linq to SQL still a viable choice for application development? - .netHow to get an http page using mechanized cookies? - pythonVSTO: event for Word Doc Content / Text Changes? - .netIserator.remove() является ROBUST во всех случаях в java? - javaIs there an equivalent to -applicationDidReceiveMemoryWarning: on Mac - memory-managementAm I really comforting my memory? - memory-managementselect results by zip / longitude / latitude - sqlAll Articles