Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Assignment of Arrays of Hashes

by blm (Hermit)
on Oct 14, 2002 at 09:46 UTC ( [id://205016]=note: print w/replies, xml ) Need Help??


in reply to Assignment of Arrays of Hashes

I read your code and think that you mean something like

$content{$selector[1]} = \@inline;

When you use %hash you say eg$hash{'key'} = "Something". When you use an array eg @array you use eg $array[1] = "Something".

In case you don't know putting the following at the top of your scripts turns on useful warnings that help you catch problems quickly.

use strict; use warnings;
Update: OK, OK! I had not seen anywhere that you could do @hash{'key1', 'key2', 'key3'} = ('value1', 'value2', 'value3'); I am sorry! See Aristotle reply for explanation --blm--

Replies are listed 'Best First'.
Re^2: Assignment of Arrays of Hashes
by Aristotle (Chancellor) on Oct 14, 2002 at 11:38 UTC
    No, he is using the hash correctly. You can assign to multiple hash keys at once by saying @hash{'key1', 'key2', 'key3'} = ('value1', 'value2', 'value3');. This is known as a "slice", and that's what he's doing.

    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (None)
    As of 2024-04-25 01:51 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found