At 16:10 17.05.2002, Viljo Marrandi wrote: >Hello, > >Sorry about non mod_perl question, but as I'm subscribed to this list and >I know I can get help from here, I ask my question here. > >Can anyone tell me, what's wrong with this piece of code: > >$vars->{'key2'} = "value of second key"; >$vars = { > xxx => "AAA", > yyy => "BBB", > zzz => "CCC", >}; >$vars->{'key1'} = "value of first key"; > >foreach $a ( keys %{$vars} ) { > print "$a = $vars->{$a}\n"; >} > > >Problem is, that value of key2 is lost after I set values to xxx, yyy and >zzz, but key1 is ok. I searched through perlref, perldsc manpages, but >didn't find anything similar (maybe that's the problem?).
Reeallllyyyy OT, but ok :) You're effectively re-setting your variable here. What you do above is, if we consider simple scalars, the same as: $vars = "Foo1"; $vars = "Foo2"; What will be the value of $vars? "Foo2" of course. What are your solutions? The easiest would maybe be to do this: @{$vars}{qw/xxx yyy zzz/} = qw/AAA BBB CCC/; Or $vars->{xxx} = 'AAA', etc.... -- Per Einar Ellefsen [EMAIL PROTECTED]