quite a novel use of terminology there..
To (I think) answer your question a hash by its very nature has no concept of "order of input" as you are looking for. However there is another way. Here is one approach:
As you add things to the associative array %asco_ary you are keeping track of what order they were put there in the array @key_table. The function push adds things to an array to the end of the array which is the equivilant of saying $key_array[++$#key_array]="thing";.: : Much hand waving. : # initialize a couple of things my %asoc_ary=(); my @key_table=(); : : fanning the air some more sub putThingIn { my ($key,$value)=$_; push @key_table=$key; $asoc_ary{$key}=$value; } sub getThingsBack { foreach my $key(@key_table){ print $asco_ary{$key},$/; } }
When you iterate through the key array and use those values as your keys into your associative array you will get your values back in the order you stored therm.
In reply to Re: Sorting hash references
by blue_cowdawg
in thread Sorting hash references
by diparun
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |