TommyIndigo
Programmer
The snippet of code I'm pasting below is supposed to add a new record ONLY IF it doesn't already exists. For some reason, it is adding the record twice. Any ideas? I'm rather new to "hashes of hashes", so any advice would help. Somewhere in the "if" block is where I suspect the problem. Thanks!
Code:
#Add users to the global user list
my $UsersDataFilePath = "$ExaminedProjectPath/users/data.txt";
my $TempCGIObject;
my $UserID;
# Open the Document Data File in read mode
open(DATAFILE1, "<$UsersDataFilePath");
# Instantiate a new CGI object for each record in the user data file and store object
# reference in a hash table keyed on the unique ID field
while (!eof(DATAFILE1))
{
$TempCGIObject = CGI->new(\*DATAFILE1);
#Only add if user isn't already on this list
$UserID=($TempCGIObject->param('UserID'));
if (!defined($GlobalUserList{$UserID}))
{
$GlobalUserList{$UserID}=$UserID;
$GlobalUserList{$UserID}{EmailAddress}=($TempCGIObject->param('EmailAddress'));
$GlobalUserList{$UserID}{DomainName} = ($TempCGIObject->param('DomainName'));
$GlobalUserList{$UserID}{UserName} = ($TempCGIObject->param('UserName'));
}#end if
}#end while
# Close the data file
close(DATAFILE1);