aboutsummaryrefslogtreecommitdiff
path: root/run/p5p
diff options
context:
space:
mode:
Diffstat (limited to 'run/p5p')
-rw-r--r--run/p5p31
1 files changed, 31 insertions, 0 deletions
diff --git a/run/p5p b/run/p5p
new file mode 100644
index 0000000..ebb0c62
--- /dev/null
+++ b/run/p5p
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Net::NNTP;
+use HTML::Entities;
+
+my $nntp = Net::NNTP->new('nntp.perl.org') or die "Cannot contact nntp.perl.org: $!";
+my ($count, $first, $last) = $nntp->group('perl.perl5.porters');
+
+my %d = %{$nntp->xhdr('Date', [$last-10, $last])};
+my %f = %{$nntp->xhdr('From', [$last-10, $last])};
+my %s = %{$nntp->xhdr('Subject', [$last-10, $last])};
+
+# TODO: Escape potential HTML characters
+
+for ((reverse sort keys %d)[0..4]) {
+ $_ = encode_entities($_) for ($d{$_}, $f{$_}, $s{_});
+ $f{$_} =~ s,@[^.]*\.,@<i>hidden</i>.,;
+ print <<HTML;
+<p>
+<div style="font-size: 80%; margin: 0;">
+<span class="date" style="line-height: 1;">Date: $d{$_}</span>
+<br/><span class="from">From: $f{$_}</span>
+</div>
+<span class="subject">Subject: <a href="https://www.nntp.perl.org/group/perl.perl5.porters/0/0/msg$_.html">$s{$_}</a></span>
+</p>
+HTML
+}
+
+$nntp->quit;