in reply to Structuring maillog data - hopefully simple question on arrays/hashes

If I may add, be careful of this construct:
foreach $keys (%msgids) { if ($key =~ /$line/) { delete $msgids $key; } }
You probably meant:
foreach $key (keys %msgids) { if ($key =~ /$line/) { delete $msgids{$key} } }
This will probably create a large temporary list in memory (keys %msgids) (and you seem to be missing a close brace).
A better way to iterate through a hash is to use each:
while (($key, $value) = each(%msgids)) { if ($key =~ /$line/) { delete $msgids{$key} } }

Replies are listed 'Best First'.
Re^2: Structuring maillog data - hopefully simple question on arrays/hashes
by billie_t (Sexton) on Jun 12, 2007 at 06:57 UTC
    Ack, yes, my grasp of hashes is shaky at best, and it helps if I use the correct syntax! That while loop syntax is great - it looks much better, and I made heavy use of it (in my ugly script below). Thanks for the help!