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

foreach( @ARGV ){
    print "converting: $_\n";
    convert($_)
    foreach( <$_/M.*.A> );
}

sub convert
{
    my($fn) = @_;
    $content < io($fn);
    $content =~ s/\r//gs;
    $content =~ s/\^R//gs;
    $content =~ s/^.*?m 作者 .*?m (.*\))\s+$/作者: $1/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);
}