Skip to content

Instantly share code, notes, and snippets.

@ckhung
Last active August 3, 2023 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckhung/8da9a599fdee8a139e57473d56fa1fd2 to your computer and use it in GitHub Desktop.
Save ckhung/8da9a599fdee8a139e57473d56fa1fd2 to your computer and use it in GitHub Desktop.
From a plurk mail in html format, generate a summary
#!/usr/bin/perl -w
# plurk mail summary
# plurk-sent mail
# => *.mbox (by gmail)
# => *.html (by hypermail)
# => *.txt (by lynx -dump)
# => plk-ms.perl
# e.g.
# hypermail -m plurk.mbox -d plurk
# for f in plurk/????.html ; do lynx -dump $f | perl plk-ms.perl ; done | sort > ~/plurk-summary.txt
use strict;
my ($subj, %count, %month, @keys, $k, $m);
%month = (
Jan => 1,
Feb => 2,
Mar => 3,
Apr => 4,
May => 5,
Jun => 6,
Jul => 7,
Aug => 8,
Sep => 9,
Oct => 10,
Nov => 11,
Dec => 12,
);
while (<>) {
if ($.==1) {
$subj = $_;
next;
} else {
++$count{$1} if (m#(https://www.plurk.com/p/\w+)#);
printf("%02d%02d%02d $4 # ", $3, $month{$2}, $1) if /Date:.*?(\d+)\s+([A-Z]\w\w)\s+20(\d\d)\s+(\d\d:\d\d:\d\d)/;
}
}
@keys = keys %count;
$m = $keys[0];
for $k (@keys) {
$m = $k if ($count{$k} > $count{$m});
}
print("$m ") if $#keys >= 0;
print($subj);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment