in reply to hash on memory or disk?

As well as what Abigail said, how are you reading your log file? If you're doing something like ...
@log_entries = <LOGFILE>;
then you'll be slurping the whole file into memory. Better to do ...
while(<LOGFILE>) { # stuff to process this single log entry }
This:
$maillist{$hostqid}=$mail; $msgid=${maillist{$hostqid}}->msgid; delete $maillist{$hostqid}; $maillist{$hostqid}=$nmail;
also looks weird. You assign to $maillist{$hostqid}, then use it, then immediately delete the hash entry, then immediately assign a new value to it.