As far as the behavior of exists...I don't have your full source so I don't
know.  I would recommend going back and making sure you NEVER touch
$AccumHash{whatever}.  Look for defines (instead of exists), method calls
(such as $AccumHash{whatever}->DataDate()) or anything that might autovivify
$AccumHash{whatever}. Furthermore, keys(%AccumHash) = 0 doesn't do what I
think you want to do.  To empty a hash, try %AccumHash = ();

Also, you should be able to update the DataDate member by saying
$ref->DataDate('MyDate');



-----Original Message-----
From: Ron Rohrssen
To: Gibbs Tanton - tgibbs; 'Perl Beginners '
Sent: 8/22/2001 10:48 AM
Subject: RE: Hash of structures not working in latest Perl build on Window
s?

THANKS!

That did work. Well, sort of....

Now there are errors in this:
if (exists($AccumHash{$lclKey}) == 1)
{
        #add data to existing structure in the hash
}
else
{
        #create new struct and add to hash
}

The very first time that I hit this code (the hash is empty), the exists
function returns a 1 and steps into the code for an existing structure
in
the hash. There's no way that the hash contains anything.

I've even tried this to insure that the hash is empty prior to hitting
the
above code for the first time.
keys(%AccumHash) = 0;

This leads to problems in other areas of the code as additional
references
to the hash cause unblessed references.

Another interesting effect is that I still have to update values in the
structure the "old" way. So, this only seems to effect reading the data
from
the structure.


Ron

-----Original Message-----
From: Gibbs Tanton - tgibbs [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 21, 2001 5:53 PM
To: '[EMAIL PROTECTED]'; 'Perl Beginners '
Subject: RE: Hash of structures not working in latest Perl build on
Window s?


Ok...I ran this on Unix with a simplified version and got the same
results
as you.

I'm not too familiar with Class::Struct, but if you specify your print
as
$AccumHash{$curr_key}->DataDate()
instead of
$AccumHash{$curr_key}{DataDate} it should work.  I'm not sure why the
underlying implementation changed, but
apparently it did...I would recommend changing to use the function
interface.

Good Luck!
Tanton

-----Original Message-----
From: Ron Rohrssen [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 21, 2001 5:17 PM
To: Gibbs Tanton - tgibbs; 'Perl Beginners '
Subject: RE: Hash of structures not working in latest Perl build on
Window s?


There aren't any error messages.

On the older Perl versions it will print out data stored in the
structure.
(i.e. DataDate in the example code). On the newer version 5.6.1, every
data
field in the structure is "" (empty string). Although, I can loop
through
the hash and correctly retrieve the keys.

I just can't get data stored in the structure.

Ron

-----Original Message-----
From: Gibbs Tanton - tgibbs [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 21, 2001 5:03 PM
To: 'Ron Rohrssen '; 'Perl Beginners '
Subject: RE: Hash of structures not working in latest Perl build on
Window s?


What does it not do...what did it used to do...are there any error
messages
or warnings now?

-----Original Message-----
From: Ron Rohrssen
To: Perl Beginners
Sent: 8/21/2001 3:49 PM
Subject: Hash of structures not working in latest Perl build on Windows?

I have a section of code the works on Win 98 and NT using Perl version
5.005_03.

However, the same code does not work under Win NT using Perl version
5.6.1.

Can someone help me identify why this does not work in the latest Perl
version?

Here is a code snippet.
-----------
#Create the hash with code like this
struct ReportStruct => {       # The data to store for accumulated data
 CallsTDD    => '$',   #A count of the number of calls meeting the TDD
criteria
 CallsVoice   => '$',   #A count of the number of calls meeting the
voice
criteria
 DataDate    => '$',   #The actual date when the BDR was cut, does not
include time
};


if (exists($AccumHash{$lclKey}) == 1)
 {
  $AccumHash{$lclKey}{CallsVoice} = $AccumHash{$lclKey}{CallsVoice} +
int($CallsVoice);
  $AccumHash{$lclKey}{CallsTDD} = $AccumHash{$lclKey}{CallsTDD} +
int($CallsTDD);
 }
 else #Creating a new hash element and add this to the list
 {
  $p = ReportStruct->new();    #allocate a new structure to hold the
information

  $p->CallsVoice(int($CallsVoice));
  $p->CallsTDD(int($CallsTDD));
  $p->DataDate($DataDate);

  $AccumHash{$lclKey} = $p;
 }

----------------
#Loop through the hash and work on the data in the hash
@index = sort (keys (%AccumHash));

 foreach $curr_key (@index)
 {
   print "The data date stored in the hash is
".$AccumHash{$curr_key}{DataDate}." for BDR File ".$BDR_FileName."\n";
 }

Thanks

Ron Rohrssen MCI

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

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

Reply via email to