Dear Monks,
I am new to hashes etc and wondered if you could help. I have two arrays placed in a hash: one contains numbers, the other contains + and - signs related to each number. I have a third array not in the hash which i am using to compare to the numbers in the hash and extract the corresponding sign when they match. I know that hashes are mixed up (e.g. not in insertion order), but when my number matches, not only would I like to extract the corresponding sign, but i would also like to extract the next sign in the sequence e.g
$i and
$i+1 - this is the part that i'm confused about. Here's my code below - hope you can help !
my %hash = map { $numbers[$_] => $signs[$_]} 0 .. $#numbers;
while (($key, $value) = each (%hash)) {
if (@new_numbers) {
for (my $i=0; $i<@new_numbers; $i++) {
if ($key == $new_numbers[$i]) {
print "$value \t $new_numbers[$i]"; # th
+is prints the sign and the number it matches to
}
}
}