01 #!/usr/local/bin/perl -w 02 use strict; 03 use local::lib; 04 use Text::CSV; 05 06 my $logfile = "perl-git-log.txt.bz2"; 07 my $csvfile = "perl-git-log.csv"; 08 09 my $csv = Text::CSV_XS->new ( { binary => 1, eol => $/ } ) or 10 die "Cannot use CSV: ", Text::CSV->error_diag(); 11 12 open my $logfh, "bzip2 -dc $logfile |" or die "$logfile: $!"; 13 open my $csvfh, ">$csvfile" or die "$csvfile: $!"; 14 15 my($dummy, $author, $time, $committer); 16 17 $csv->print( $csvfh, ["time", "file", "author", "committer"] ); 18 19 while( <$logfh> ) { 20 if( /^commit/ ) { 21 chomp; 22 ($dummy, $author, $time, $committer) = split /,/, $_; 23 } elsif( /^(\w)\s+(.*)/ ) { 24 my $file = $2; 25 $csv->print( $csvfh, [$time, $file, $author, $committer] ) or 26 die "print failed: ", Text::CSV->error_diag(); 27 } 28 } 29 30 close $logfh or die "$logfile: $!"; 31 close $csvfh or die "$csvfile: $!";