in reply to Re: multidimenional hashes
in thread multidimenional hashes

Thanks. But does that mean that I have no way of referencing a hash value by giving an "index + offset"? For example, I want to be able to say things like
$fval{$flat[$i]+0.25}{$flong[$i]}

Replies are listed 'Best First'.
Re: Re: Re: multidimenional hashes
by busunsl (Vicar) on Oct 11, 2002 at 13:03 UTC
    You can, you just have to format the value:
    $fval{sprintf('%3.6f', $flat[$i]+0.25)}{$flong[$i]}
Re: Re: Re: multidimenional hashes
by fglock (Vicar) on Oct 11, 2002 at 13:08 UTC

    Maybe you'd better be sure that your keys are are not formatted numbers:

    $fval{$flat[$i]+0}{$flong[$i]+0}
      Yes! Thank you. (but, i still don't see what went wrong in my original example, since I "replicated" the string that was being stored in the variable, and yet still the hash value was undefined.)
        The compiler stores the numbers in your source code as numbers not as formated text. When you do something with it that requires a string it gets "stringified". Here is an example:
        $string = "39.750000"; $number = 39.750000; print "$string $number\n"; __OUTPUT__ 39.750000 39.75
        As you can see when the runtime stringifies $number it is not necessarily going to be in the same format as in the source code. So do your hash keys with either formatted text using sprintf or numbers by adding zero. I would probably use formatted strings, sometimes floating point numbers can be inconsistent due to their internal representation in hardware.

        --

        flounder