File: parse_apache_changes.pl

package info (click to toggle)
libapache2-mod-perl2 2.0.9~1624218-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 11,840 kB
  • sloc: perl: 95,064; ansic: 14,522; makefile: 49; sh: 18
file content (57 lines) | stat: -rwxr-xr-x 1,184 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
use strict;

package ChangesPodFormatter;
use base qw(Pod::Simple::Methody);

sub start_Document {
    my $self = shift;
    $self->{state} = 'Doc';
    $self->{year} = '';
    if (not exists $self->{contributers}) {
        $self->{contributers} = {};
    }
}

sub start_item_text {
    my $self = shift;
    $self->{state} = 'Item';
    return;
}

sub end_item_text {
    my $self = shift;
    $self->{state} = 'Doc';
    return;
}

sub handle_text {
    my ($self, $text) = @_;
    if ($self->{state} eq 'Item') {
        if ($text =~ /\w+\s+\d{1,2},\s+(\d{4})$/) {
            my $year = $1;
            $self->{year} = $year;
        }
        else {
            print "$text\n";
        }
    }
    else {
        foreach my $c ($text =~ /\[([\w\s\<\>\@\.\-]+)\]/g) {
            $self->{contributers}->{$c}->{$self->{year}} = 1;
        }
    }
    return;
}

1;
package main;
my $parser = ChangesPodFormatter->new;
$parser->parse_file('Apache-Test/Changes');
$parser->parse_file('Changes');
foreach my $c (keys %{$parser->{contributers}}) {
    my %years = %{$parser->{contributers}->{$c}};
    print join ", ", sort keys %years;
    print ", $c\n";
}
exit 0;