i need help with this one :) the point of this problem is that i'm looking for a way to retrace my steps. let say i have this hash that is only declared & initialized like this:
also let say this hash is a class variable. and thet every time the class method is called the result of its calculation is pushed into a hash, like this:use strict; use Data::Dumper; my %hash; %hash = (key1 => [1], key2 => [1], key3 => [1]);
so now i'm looking for a procedure to retrace the exact order in which i inputed the last data into my hash. in other words i would like to receive data in following order:push(@{$hash{key2}},4); push(@{$hash{key3}},8); push(@{$hash{key1}},7); push(@{$hash{key2}},9); $hash{key4} = [8]; push(@{$hash{key2}},9); push(@{$hash{key3}},2);
i don't know if you understand what am i aiming for. the data structure has to be in the hash form and only thing that interests me how to retrieve those data from that hash in revers order they were entered into the hash.foreach (hash key){ my $last_one = pop(@{$hash{$_}}); print "$_ $last_one \n"; } so that rtesult is going to be: key3 2 key2 9 key4 8 key1 7 and in next iteration : key2 9 key3 8 key1 1
any ideas??? (i'm not looking for the actual code but just an idea :))
thank you
In reply to retrieving hash keys by baxy77bax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |