summaryrefslogtreecommitdiffstats
path: root/ColaBBS_to_PttBBS/cntmail.pl
blob: bb67f49a177a7280927e2f8587a698743d51372b (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
#!/usr/bin/perl
# $Id$
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);
}