#!/usr/bin/perl use strict; use warnings; use Net::NNTP; use HTML::Entities; my $nntp = Net::NNTP->new('nntp.perl.org', Timeout => 10) 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,@[^.]*\.,@hidden.,; my $l = "https://www.nntp.perl.org/group/perl.perl5.porters/0/0/msg$_.html"; print <
Date: $d{$_}
From: $f{$_}
$s{$_}
HTML } $nntp->quit;