Add example
[gipeda.git] / example / log2csv
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use File::Basename;
7 use File::Slurp;
8 use IPC::Run qw/run/;
9
10 for my $filename (@ARGV) {
11         my $log = read_file($filename);
12
13         for (split /^/, $log) {
14                 printf "loc/haskell;$1\n"
15                         if (m/^haskell\s+\d+\s+(\d+)/);
16                 printf "loc/JavaScript;$1\n"
17                         if (m/^javascript\s+\d+\s+(\d+)/);
18                 printf "loc/HTML;$1\n"
19                         if (m/^html\s+\d+\s+(\d+)/);
20                 printf "loc/CSS;$1\n"
21                         if (m/^css\s+\d+\s+(\d+)/);
22                 printf "comment-rate;$1\n"
23                         if (m/^Total\s+\d+\s+\d+\s+\d+\s+([\d\.]+)%/);
24         }
25 }