summaryrefslogtreecommitdiffstats
path: root/ColaBBS_to_PttBBS/cntarticle.pl
blob: 36419b5ad72cc20828602472ade8ef8ce91e68f7 (plain) (blame)
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
#!/usr/bin/perl
# $Id$
use IO::All;
die "usage: cntarticle.pl [base dir]"
    if( !@ARGV );

@proc = @ARGV;
while( $dir = pop @proc ){
    print "converting: $dir\n";
    while( <$dir/*> ){
    next if( /^\./ );
    if( -d $_ ){
        push @proc, $_;
    } elsif( /M\..*\.A/ ){
        convert($_);
    }
    }
}

sub convert
{
    my($fn) = @_;
    $content < io($fn);
    $content =~ s/\r//gs;
    $content =~ s/^.*?m 作者 .*?m (.*\))\s+\S+? 信區 .*?m (\S+).*/作者: $1 看板: $2/m;
    $content =~ s/^.*?m 標題 .*?m (.*?)\s+\S+m/標題: $1/m;
    $content =~ s/^.*?m 時間 .*?m (.*?)\s+\S+m/時間: $1/m;
    $content =~ s/^\e\[36m────────────────────────────────────────\e\[m\n//m;
    "$content\n" > io($fn);
}