Deleting duplicate values in hash of hashes



hello everyone,

Not sure how I can do this in the most efficient way. Hoping
someone will enlighten me on how I can go about doing it..

I have written a script on a sendmail 'gateway' server. (gateway for
an Exchange backend.) The script creates a report of all the
successfully transmitted emails to three particular email addresses.
Here is what I do...

First I read through the mail log file and search for all the
message id's for each of the three email addresses. Since the
information I need is not contained in one single line of the mail log,
I re-read the mail log , skipping any line that does not pertain to
what I am looking for.

The second time reading the log file I generate a hash of hashes..

$HoH{$msgid}{exchange} = The id the Exchange server assigned to the
email.
$HoH{$msgid}{year}
$HoH{$msgid}{day}
$HoH{$msgid}{time}
$HoH{$msgid}{status}

The problem I am having is that MS Exchange is sending multiple
messages, where the $HoH{$msgid}{exchange} is the same value, but the
$HoH{$msgid} value is different.

Is there a way I can remove duplicate $HoH{$msgid}{exchange} values is
the message id is different?

I thought I could see if it was defined before I populated the hash..
But I am not even getting close to the results I thought I would get..



code...


if($text =~ /^to\=</){
#check status first.
my $status = (split /stat\=/, $text)[1];
if ($status =~ /Sent\s\(/){

$HoH{$msgid}{status} = $status;
$HoH{$msgid}{date} = $date;
$HoH{$msgid}{time} = $time;
$HoH{$msgid}{year} = $year;

}else{
# we don't care about no delivered.
next;
}

#grab the email address
my($eMail) = (split /\s+/, $text)[0];

#clean up the output a little
$eMail =~ s/to\=<//;
$eMail =~ s/>,//;

$HoH{$msgid}{email} = $eMail;
}


#add exchange id to the hash.
if($text =~ /msgid\=</){
my($exchange) = (split /\s+/, $text)[4];

#clean up the output a little
$exchange =~ s/msgid\=<//;
$exchange =~ s/>,//;

## Thought I could determine if $exchange existed and not add
it.
$HoH{$msgid}{exchange} = $exchange;
next;
}



Thanks for the help...


Sincerely,
sunckell

.



Relevant Pages

  • Re: Exchange services wont start on clean SBS 2003 install
    ... I have found several people in exchange and sbs groups ... using nothing but the wizards on a clean format. ...
    (microsoft.public.windows.server.sbs)
  • Re: [Fwd: Re: Writer Processor (was Re: Ubuntu vs. Debian ...)]
    ... Hash: SHA1 ... Change tracking in word is a horrible feature. ... Heck Exchange is good for SOMETHING, ...
    (Debian-User)
  • Re: Anti Spam Loesung in der DMZ
    ... SMTP Adresse) ist als hash dort abgelegt. ... na ja wer Edge will muss damit leben. ... Also selbst wenn intern Mails an Postfix etc gehen? ... Frank Carius MS Exchange MVP ...
    (microsoft.public.de.exchange)
  • Re: Exchange 2003 (2 Sites into 1)
    ... is there any real documentation to make sure the order is done ... Forces the users to clean up a bit and takes ... >> a company awhile back who has a stand-alone Exchange 2003 environment. ...
    (microsoft.public.exchange.setup)
  • Re: Mail bounces back from Exchange ONLY
    ... IP from Verizon and our domain IP and name and they all come up clean. ... Exchange) can send mail to the mercercolor.com domain. ... our ISP directly and not through our Exchange server and their email goes ... as most dynamic ranges are entirely on blacklists. ...
    (microsoft.public.windows.server.sbs)