[tpm] Schrodinger's hash ?

Indy Singh indy at indigostar.com
Fri Jun 22 11:30:43 PDT 2012


I would just change the while loop to:
foreach (keys %hash) {
    $index = $_;
   $object = $hash{$index}
}

It doesn’t explain why your hash appears empty, but if the print work, then this code should work just as well.

A while on an array or hash is odd coding, unless you intend to change the array inside the loop – but that is an odd thing to do too.

Indy Singh
IndigoSTAR Software -- www.indigostar.com

From: Fulko Hew 
Sent: Friday, June 22, 2012 1:36 PM
To: TPM 
Subject: [tpm] Schrodinger's hash ?

I have a mysteriously disappearing hash...

If I look at it (in advance) it contains stuff,
but if I just 'use' it, then its empty... Schrodinger's ghost?


I have the following fragment:

    ...
    #print "varbindTable num keys: ", scalar keys %varbindTable, "\n";
    while (($index, $object) = each %varbindTable) {
        ... do loopy stuff ...
    }

If I enable the print statement and run my code, the hash 'contains stuff'.
but if I comment it out, the while loop is skipped.

Huh?

(Of course there is a ton more code around this fragment
and 'no', I don't have a minimal repeatable example.)

Has anyone seen such a behavior?

TIA
Fulko




--------------------------------------------------------------------------------
_______________________________________________
toronto-pm mailing list
toronto-pm at pm.org
http://mail.pm.org/mailman/listinfo/toronto-pm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20120622/e59f7bbe/attachment.html>


More information about the toronto-pm mailing list