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

Yes:

my %hash; $hash{key1} = 'longstring'; $hash{key2} = alter($hash{key1});

Admittedly, you have to change your initialization syntax somewhat. The reason is that list on the right hand side of the = is built before the assignment even starts. (See perlop for operator precedence.) Some people seem to think %h = (a=>b, c=>d); is a hash constructor/initializer, but it's not. It's simply a list which gets assigned to a hash.

Replies are listed 'Best First'.
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:25 UTC
    /me goes to delve into perlop. Thanks!