I'd try something like this, in the assumption that all lines have the same number of numerical columns:
my @prev;
local($\, $,) = ("\n", " ");
while(<DATA>) {
my($date, $time, @current) = split " ";
if(@prev) {
print $date, $time, map { $current[$_] - $prev[$_] } 0 .. $#cu
+rrent;
}
@prev = @current;
}
__DATA__
02/02/2007 00:00:00 719267027 719244316 719233953 719240015
02/03/2007 00:00:00 720375777 720336674 720325633 720329849
02/04/2007 00:00:00 721640280 721640267 721522690 721552815
02/05/2007 00:00:00 722297206 722297203 722297203 722297206
(written so it uses the enclosed test data)
Result:
02/03/2007 00:00:00 1108750 1092358 1091680 1089834
02/04/2007 00:00:00 1264503 1303593 1197057 1222966
02/05/2007 00:00:00 656926 656936 774513 744391
To turn this into something that reads from a file instead of from the list of data near the end of the script, replace the <DATA> with <> and pass the file name on the command line. |