just want to share with other unwary folk the pitfalls
of making an assumption about perl (or anything for that matter)



i tried for the longest time to get something like
the following to work::

foreach $section (keys %board){

        for my $a (1..19){
                for (1..19){
                $board->{"Q1S1"}->[$a]->[$_] and print "\n$a    $_";
                $board->{"Q1S2"}->[$a]->[$_] and print "\n$a    $_";
                $board->{"Q2S1"}->[$a]->[$_] and print "\n$a    $_";
                $board->{"Q2S2"}->[$a]->[$_] and print "\n$a    $_";
                $board->{"Q3S1"}->[$a]->[$_] and print "\n$a    $_";
                $board->{"Q3S2"}->[$a]->[$_] and print "\n$a    $_";
                $board->{"Q4S1"}->[$a]->[$_] and print "\n$a    $_";
                $board->{"Q4S2"}->[$a]->[$_] and print "\n$a    $_";
                }
        }
}


well, it is supposed to repeat the inner loops several times over right?
for each hashkey, do the following.... etc etc..

if i got rid of the "foreach $section (keys %board){"
the rest would work fine.  I was about to yell at you guys about it
when, out of desperation, i tried one last thing :

my $board = \%board; #first line in the whole thing

and it WORKS!!!!


It turns out that a reference to a hash that's created on the 'spur of
the moment' and not explicitly made to refer to a %HASH doesn't work
the same way as a real hash :P

now that i've figured this out, i would love to learn a bit about
/how/ this works.

$board ->{"blah"}  is different from $board = \%board; $board->{"blah"}

i think i understand, but would like a clear explanation anyway.


btw- i know it looks like nonsense code, but i cut out some
details in the cut and paste *shrug*  - just testing some functions on
an individual basis.....



thanks,
        willy

:)
  

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to