Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: How to assign an array to a value in hash?

by periapt (Hermit)
on Apr 22, 2004 at 12:33 UTC ( #347327=note: print w/replies, xml ) Need Help??


in reply to How to assign an array to a value in hash?

Your problem occurs in the mixed use of array and scalar values. The assignment $new_hash{$some_key1} = @some_array1 actually references @some_array1 in the scalar context (because $new_hash{$some_key1} is of the scalar data type). In the scalar context @some_array1 will simply return the number of elements in the array. If you want to save the actual array, assign a reference to the array into the hash such as $new_hash{$some_key1} = \@some_array1. This will preserve the array. You can now reference the elements of the array as $new_hash{$some_key1}[0], $new_hash{$some_key1}[1] etc

PJ

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://347327]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2022-01-29 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (74 votes). Check out past polls.

    Notices?