#!/usr/bin/perl # # Toomas Karmo # http://www.metascientia.com # # For maintenance of weekly timelogs, # as discussed in the Linux timekeeping essay # in the "Literary" section of # http://www.metascientia.com, # and further discussed in the "Unix" subsection # of the "Technical" section # of http://www.metascientia.com. # # # $totals{'AA'} = 0; $totals{'aa'} = 0; $totals{'BB'} = 0; $totals{'bb'} = 0; $totals{'CC'} = 0; $totals{'cc'} = 0; $totals{'DD'} = 0; $totals{'dd'} = 0; $totals{'EE'} = 0; $totals{'ee'} = 0; $totals{'FF'} = 0; $totals{'ff'} = 0; $totals{'GG'} = 0; $totals{'gg'} = 0; $totals{'HH'} = 0; $totals{'hh'} = 0; $totals{'II'} = 0; $totals{'ii'} = 0; $totals{'JJ'} = 0; $totals{'jj'} = 0; while(chop($line=)) { if ($line =~ /^SUN|^MON|^TUE|^WED|^THU|^FRI|^SAT/) { $AA = $line; $AA =~ s/^.{4}(.{2}).*/\1/; $totals{'AA'} = $totals{'AA'} + $AA; $aa = $line; $aa =~ s/^.{7}(.{2}).*/\1/; $totals{'aa'} = $totals{'aa'} + $aa; $BB = $line; $BB =~ s/^.{12}(.{2}).*/\1/; $totals{'BB'} = $totals{'BB'} + $BB; $bb = $line; $bb =~ s/^.{15}(.{2}).*/\1/; $totals{'bb'} = $totals{'bb'} + $bb; $CC = $line; $CC =~ s/^.{18}(.{2}).*/\1/; $totals{'CC'} = $totals{'CC'} + $CC; $cc = $line; $cc =~ s/^.{21}(.{2}).*/\1/; $totals{'cc'} = $totals{'cc'} + $cc; $DD = $line; $DD =~ s/^.{24}(.{2}).*/\1/; $totals{'DD'} = $totals{'DD'} + $DD; $dd = $line; $dd =~ s/^.{27}(.{2}).*/\1/; $totals{'dd'} = $totals{'dd'} + $dd; $EE = $line; $EE =~ s/^.{32}(.{2}).*/\1/; $totals{'EE'} = $totals{'EE'} + $EE; $ee = $line; $ee =~ s/^.{35}(.{2}).*/\1/; $totals{'ee'} = $totals{'ee'} + $ee; $FF = $line; $FF =~ s/^.{38}(.{2}).*/\1/; $totals{'FF'} = $totals{'FF'} + $FF; $ff = $line; $ff =~ s/^.{41}(.{2}).*/\1/; $totals{'ff'} = $totals{'ff'} + $ff; $GG = $line; $GG =~ s/^.{46}(.{2}).*/\1/; $totals{'GG'} = $totals{'GG'} + $GG; $gg = $line; $gg =~ s/^.{49}(.{2}).*/\1/; $totals{'gg'} = $totals{'gg'} + $gg; $HH = $line; $HH =~ s/^.{52}(.{2}).*/\1/; $totals{'HH'} = $totals{'HH'} + $HH; $hh = $line; $hh =~ s/^.{55}(.{2}).*/\1/; $totals{'hh'} = $totals{'hh'} + $hh; $II = $line; $II =~ s/^.{58}(.{2}).*/\1/; $totals{'II'} = $totals{'II'} + $II; $ii = $line; $ii =~ s/^.{61}(.{2}).*/\1/; $totals{'ii'} = $totals{'ii'} + $ii; $JJ = $line; $JJ =~ s/^.{67}(.{2}).*/\1/; $totals{'JJ'} = $totals{'JJ'} + $JJ; $jj = $line; $jj =~ s/^.{70}(.{2}).*/\1/; $totals{'jj'} = $totals{'jj'} + $jj; } } $totals{'AA'} = $totals{'AA'} + int($totals{'aa'} / 60.0); $totals{'aa'} = $totals{'aa'} % 60.0; $totals{'BB'} = $totals{'BB'} + int($totals{'bb'} / 60.0); $totals{'bb'} = $totals{'bb'} % 60.0; $totals{'CC'} = $totals{'CC'} + int($totals{'cc'} / 60.0); $totals{'cc'} = $totals{'cc'} % 60.0; $totals{'DD'} = $totals{'DD'} + int($totals{'dd'} / 60.0); $totals{'dd'} = $totals{'dd'} % 60.0; $totals{'EE'} = $totals{'EE'} + int($totals{'ee'} / 60.0); $totals{'ee'} = $totals{'ee'} % 60.0; $totals{'FF'} = $totals{'FF'} + int($totals{'ff'} / 60.0); $totals{'ff'} = $totals{'ff'} % 60.0; $totals{'GG'} = $totals{'GG'} + int($totals{'gg'} / 60.0); $totals{'gg'} = $totals{'gg'} % 60.0; $totals{'HH'} = $totals{'HH'} + int($totals{'hh'} / 60.0); $totals{'hh'} = $totals{'hh'} % 60.0; $totals{'II'} = $totals{'II'} + int($totals{'ii'} / 60.0); $totals{'ii'} = $totals{'ii'} % 60.0; $totals{'JJ'} = $totals{'JJ'} + int($totals{'jj'} / 60.0); $totals{'jj'} = $totals{'jj'} % 60.0; if ($totals{'AA'} < 10) { $totals{'AA'} = '0'.$totals{'AA'}; } if ($totals{'aa'} < 10) { $totals{'aa'} = '0'.$totals{'aa'}; } if ($totals{'BB'} < 10) { $totals{'BB'} = '0'.$totals{'BB'}; } if ($totals{'bb'} < 10) { $totals{'bb'} = '0'.$totals{'bb'}; } if ($totals{'CC'} < 10) { $totals{'CC'} = '0'.$totals{'CC'}; } if ($totals{'cc'} < 10) { $totals{'cc'} = '0'.$totals{'cc'}; } if ($totals{'DD'} < 10) { $totals{'DD'} = '0'.$totals{'DD'}; } if ($totals{'dd'} < 10) { $totals{'dd'} = '0'.$totals{'dd'}; } if ($totals{'EE'} < 10) { $totals{'EE'} = '0'.$totals{'EE'}; } if ($totals{'ee'} < 10) { $totals{'ee'} = '0'.$totals{'ee'}; } if ($totals{'FF'} < 10) { $totals{'FF'} = '0'.$totals{'FF'}; } if ($totals{'ff'} < 10) { $totals{'ff'} = '0'.$totals{'ff'}; } if ($totals{'GG'} < 10) { $totals{'GG'} = '0'.$totals{'GG'}; } if ($totals{'gg'} < 10) { $totals{'gg'} = '0'.$totals{'gg'}; } if ($totals{'HH'} < 10) { $totals{'HH'} = '0'.$totals{'HH'}; } if ($totals{'hh'} < 10) { $totals{'hh'} = '0'.$totals{'hh'}; } if ($totals{'II'} < 10) { $totals{'II'} = '0'.$totals{'II'}; } if ($totals{'ii'} < 10) { $totals{'ii'} = '0'.$totals{'ii'}; } if ($totals{'JJ'} < 10) { $totals{'JJ'} = '0'.$totals{'JJ'}; } if ($totals{'jj'} < 10) { $totals{'jj'} = '0'.$totals{'jj'}; } write; format STDOUT = TOT @