I'm a firm believer in doing empirical testing so I wrote a little sniglet of code:
#!/usr/bin/perl -w use strict; use Data::Dumper; my @ingredients = ( [ qw / onions diced / ], [ qw / potatos diced / ], [ qw / paprika spicy / ], [ qw / salt shaken / ], [ qw / pepper fresh / ] ); my $hash_browns={}; foreach my $ingredient (@ingredients){ $hash_browns -> { $ingredient -> [0] } = $ingredient -> [1]; } foreach my $key ( keys %$hash_browns ){ printf "%s\t%s\n",$key,$hash_browns->{$key}; }
When I run this code three times I get something like this:
Looks pretty much the same to me.[pberghol@cowdawg hash]$ perl hash.pl salt shaken onions diced pepper fresh paprika spicy potatos diced [pberghol@cowdawg hash]$ perl hash.pl salt shaken onions diced pepper fresh paprika spicy potatos diced [pberghol@cowdawg hash]$ perl hash.pl salt shaken onions diced pepper fresh paprika spicy potatos diced
Now, I'm not sure why this is all important, but if I were looking for random behavior, I'd program for it and not count on a "freak of nature" in my programming language of choice to give it to me. On the other hand if predictable behavior is what I want, again I'll program for that.
In reply to Re: random behaviour of perl hashes
by blue_cowdawg
in thread random behaviour of perl hashes
by evilgoblin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |