in reply to Structuring maillog data - hopefully simple question on arrays/hashes
Firstly, I don't really see the need to run through your log file more than once. Also, I think just a single hash (a HOH, actually) would suffice for your purposes. I would use the originating message ID as the key to the hash, and then have several sub-keys such as "destination_id", "status", "source_host", "destination_host", etc. And then just populate the values for each of these as you run through the log file. Once you are done, it's just a matter of iterating through your hash keys and outputting those of interest.
The second point is yes, it would be better to use a while loop to read through your log file. By using a foreach loop, you are effectively slurping the whole file into memory. Whereas a while loop will just read line by line. So something like:
Hope this helps,while (my $line = <FH>) { chomp($line); # you probably want to do this # do whatever with contents of $line }
|
|---|
| 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:52 UTC |