Have you ever wondered why it
took so long for someone’s mail to get to you? With postal
mail, you can’t trace how long each intervening post office let
your letter gather dust in their back office. But with electronic
mail, you can. The message carries in its header
lines showing when each intervening mail
transport agent along the way got the message.
The dates in the headers are hard to read. You have to read them
backwards, bottom to top. They are written in many varied formats,
depending on the whim of each transport agent. Worst of all, each
date is written in its own local time zone. It’s hard to
+0100" and realize these two dates are only 6
minutes and 25 seconds apart.
functions in the Date::Manip module from CPAN can help this:
use Date::Manip qw(ParseDate DateCalc); $d1 = ParseDate("Tue, 26 May 1998 23:57:38 -0400"); $d2 = ParseDate("Wed, 27 May 1998 05:04:03 +0100"); print DateCalc($d1, $d2);
That’s a nice format for a program to read, but it’s still not what the casual reader wants to see. The hopdelta program, shown in Example 3.1, takes a mailer header and tries to analyze the deltas (difference) between each hop (mail stop). Its output is shown in the local time zone.
Example 3-1. hopdelta
#!/usr/bin/perl # hopdelta - feed mail header, produce lines # showing delay at each hop. use strict; use Date::Manip qw (ParseDate ...