Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: adding to a hash

by Fastolfe (Vicar)
on May 13, 2003 at 23:49 UTC ( #257935=note: print w/ replies, xml ) Need Help??


in reply to Re: adding to a hash
in thread adding to a hash

Remember that = is an assignment operator, not an addition or concatenation operator. When you use it, you are telling Perl to set the left-hand side equal to the right-hand side. All entries in the hash will be replaced.

You have two options: You can either iterate through the replacement key/value pairs and set the $hash{$key} = $value, or if your list of keys and values are known ahead of time, a hash slice might let you make a change to a group of hash entries with one statement (e.g. @hash{@new_keys} = @new_values).


Comment on Re: Re: adding to a hash
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2014-10-25 15:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (145 votes), past polls