Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Hash dereferencing in a loop

by hdb (Monsignor)
on Jun 07, 2013 at 16:42 UTC ( #1037706=note: print w/replies, xml ) Need Help??

in reply to Hash dereferencing in a loop

In your first version  $hashRef{$key}, you make use of %hashRef which is not declared. Change it to  $hashRef->{$key} and you should be fine. No need to do a copy as in your workaround which would be wasteful if the hash is large.

Replies are listed 'Best First'.
Re^2: Hash dereferencing in a loop
by sundialsvc4 (Abbot) on Jun 08, 2013 at 14:21 UTC

    Also, you may encounter “double-$” syntax:   $$hashref{$key}.

    The two are equivalent, and notice in this case that the -> symbol does not appear.   Recommend that you consistently use one or the other (your choice) in your programs.   (Double-$ is less common.)

    Also note that, in cases where a sequence of -> symbols would technically be required, to reference elements of a hashref that contains hashrefs, Perl allows the additional ones to be omitted.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1037706]
[thao4]: I posted my question, Could you help me , Please ?
[thao4]: posted with the title :Replace a patern_2 in 30 lines from the line with the patern_1 founded
[Eily]: karlgoethebier but we're trying to stay hidden!
[shmem]: thao4 example of the text and program missing in your post
[Eily]: also you can use <p> or <br /> tags to have multiple lines

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2018-02-21 10:13 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (277 votes). Check out past polls.