Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Is it possible to use key/values of a Hash/Hash ref while it's being initialized?

by shiza (Hermit)
on Sep 14, 2005 at 20:04 UTC ( [id://491996]=note: print w/replies, xml ) Need Help??


in reply to Re: Is it possible to use key/values of a Hash/Hash ref while it's being initialized?
in thread Is it possible to use key/values of a Hash/Hash ref while it's being initialized?

Yes, I was aware of that. I didn't know if there was some backdoor/hack/trick to access the current hash being initialized. Thanks for the feedback!
  • Comment on Re^2: Is it possible to use key/values of a Hash/Hash ref while it's being initialized?

Replies are listed 'Best First'.
Re^3: Is it possible to use key/values of a Hash/Hash ref while it's being initialized?
by merlyn (Sage) on Sep 14, 2005 at 21:54 UTC
    the current hash being initialized
    That hash is necessarily empty until the entire value on the right (the map) is completely computed. You can't start shoving values into there because you can't alter the existing data, or else things like this woudn't work:
    @a = map { $a[$_] > 1 ? $a[$_] * 2 : () } 0..$#a;
    In this case, you can't start altering @a during the map, because @a might be getting shorter, and then you wouldn't have the right values on the right.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-20 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found