>>>>> "RA" == Russ Allbery <[EMAIL PROTECTED]> writes:
RA> Damien Neil <[EMAIL PROTECTED]> writes:
>> Arrays are ordered. Hashes are not. Sure, you can iterate over a hash,
>> but add an element to one and you can change the order of everything in
>> it.
RA> Formally, I believe it's permissable for a hash implementation to
RA> return a different order the second time you iterate through it
RA> from the first time, even if you haven't touched the hash
RA> inbetween. That's the definition of an iterable but unordered
RA> data structure; there's some way of getting all of the members one
RA> and only one time, but each time you look at it the order in which
RA> the members show up may be different (maybe garbage collection
RA> happened behind the scenes, the hash was reorganized due to an
RA> observation of how you were using it, etc.).
this will break this use of hash slices:
%add_hash = ( foo => 3, bar => 4 ) ;
%new_hash = ( joe => 5, mary => 8 ) ;
@new_hash{ keys %add_hash } = values %add_hash ;
in fact this feature is not really well documented but it is used and
relied upon. at any point a hash should have the same order of iteration
so you can correlate a list of its keys to a list of its values.
uri
--
Uri Guttman --------- [EMAIL PROTECTED] ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com