#!/usr/bin/perl #* Saturday, July 22, 2006 19:41:14 PDT - Saturday, July 22, 2006 20:13:23 PDT [0.54] [0.54] # - Set up dns slave/master between alpha and beta # \Fee{\begin{itemize*} # \item setting up rsyncd.conf to sync home directories # \item running a test rsync # \item add back missing accounts # \end{itemize*} # }{50.00}{0.94} use warnings; use strict; use Params::Validate qw(validate_with :types); my $time = undef; my $date = undef; my $hourly_rate = 50.00; my $total = 0; my @events; print<<'EOF'; \setlength\LTleft{0pt plus 1fill minus 1fill}% \let\LTright\LTleft \begin{longtable}{|p{9cm}|r|r|r|r|}% % \caption*{} \hline Description & Item Cost & Quantity & Cost & Total \\ EOF while (<>){ if (/^\s*\*\s*([^-]+)\s+-.+\[([^\]]+)\]\s*\[[^\]]+\]/) { if (defined $time) { print format_events(date => $date, time => $time, total => \$total, events => \@events); } @events = (); $date = $1; $time = $2; } if (/^\s+\-\s*(.+)/) { my $event = $1; chomp $event; push @events, $event; } } if (defined $time) { print format_events(date => $date, time => $time, total => \$total, events => \@events); } sub format_events{ my %param = validate_with(params => \@_, spec => {time => {type => SCALAR, }, date => {type => SCALAR, }, total => {type => SCALARREF, }, events => {type => ARRAYREF, }, }, ); ${$param{total}} += $param{time} * $hourly_rate; $param{date} =~ s/\s+\d+\:\d+\:\d+\s+[A-Z]{0,3}\s*//; my $output = '\hline'."\n".' \mbox{'.$param{date}."}\n\n". ' \begin{itemize*}'."\n"; $output .= join('',map {" \\item $_\n"} @{$param{events}}); $output .= ' \end{itemize*} & \$'.sprintf('%.2f',$hourly_rate).' & '.sprintf('%.2f',$param{time}). ' & \$'.sprintf('%.2f',$param{time}*$hourly_rate).' & \$'. sprintf('%.2f',${$param{total}}) . ' \\'."\n"; return $output; } print<<'EOF'; \hline\hline \multicolumn{4}{|r|}{\textbf{Total}} & \$% EOF print sprintf('%.2f',$total)."%\n"; print<<'EOF'; \\ \hline \end{longtable} EOF