in reply to Simple concatenation of hashes

I can't come up with a situation where this is not what you want. Consider:

$a = 1; $a = 2; print "\$a is $a\n"; $a[0] = 1; $a[0] = 2; print "\$a[0] is $a[0]\n"; $a{key} = 'value'; $a{key} = 'newvalue'; print "\$a{key} = $a{key}\n";

While, of course, you can't rely on the keys of %a coming out in any particular order, why would you expect the keys of %b to come out before the keys of %a?

If it ever changes, yes, it's a bug in Perl. It won't change.

Replies are listed 'Best First'.
Re: Re: Simple concatenation of hashes
by Anonymous Monk on Aug 15, 2003 at 03:29 UTC

    I agree that it's the logical behavior. But I think there's a difference between your examples and mine: in your examples, you are comparing two different statements, which have a definite execution order. In this case, you have a list, which does have a definite order -- in     %c=(%a, %b); the keys and values of %b come after the keys and values of %a. But the question is whether that order plays a predictable role in the conversion of the list into a hash.

    Common sense says that it should. But common sense is not always a predictor of future behavior.

Re: Re: Simple concatenation of hashes
by gholley (Initiate) on Aug 15, 2003 at 03:32 UTC
    Sorry about the double replies. I'd remove one of them, except that I accidentally made them anonymously and so can't edit them.