From d514585bbb54482ee62070bc86a7447a657afaee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Thu, 6 May 2021 14:30:32 +0200 Subject: First commit --- gen.pl | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ run/benchmark | 20 ++++++++++++++++ run/blogs | 1 + run/cpan | 1 + run/p5p | 31 +++++++++++++++++++++++++ run/reddit | 1 + run/rss | 34 +++++++++++++++++++++++++++ src/index.html | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/style.css | 40 ++++++++++++++++++++++++++++++++ 9 files changed, 263 insertions(+) create mode 100644 gen.pl create mode 100644 run/benchmark create mode 120000 run/blogs create mode 120000 run/cpan create mode 100644 run/p5p create mode 120000 run/reddit create mode 100644 run/rss create mode 100644 src/index.html create mode 100644 src/style.css diff --git a/gen.pl b/gen.pl new file mode 100644 index 0000000..0b682c2 --- /dev/null +++ b/gen.pl @@ -0,0 +1,62 @@ +#!/usr/bin/perl + +# gen.pl -- generate static files for perlisdead.org + +use strict; +use warnings; +use experimental 'switch'; +use File::Copy; +use FindBin '$Bin'; + +# Change directory to script path +chdir $Bin; + +# Generate index.html +mkdir 'out' if ! -d 'out'; +open my $f, '<', 'src/index.html' or die "Could not open < src/index.html: $!"; +open my $g, '>', 'out/index.html.tmp' or die "Could not open > out/index.html.tmp: $!"; +for (<$f>) { + when (/^\.inc (.*)/) { + open my $h, '<', "inc/$1" or do { + warn "Could not open inc/$1: $!"; + next; + }; + print $g $_ while <$h>; + close $h; + } + when (/^\.eval (.*)/) { + no strict; no warnings; no experimental; + local *STDOUT = $g; + eval $1; + warn $@ if $@; + } + when (/^\.run (.*)/) { + open my $h, '<', "run/$1" or do { + warn "Could not open run/$1: $!"; + next; + }; + my $c = do { local $/; <$h> }; + close $h; + local *STDOUT = $g; + local $0 = "run/$1"; + no strict; no warnings; no experimental; + eval $c; + warn $@ if $@; + # I guess you could just shell out instead... + } + default { + print $g $_; + } +} +close $g; +close $f; + +# Copy static files +opendir my $dh, 'src' or die "Could not open directory src: $!"; +while (readdir $dh) { + copy "src/$_" => "out/$_" unless /^\./ or /^index\.html$/; +} +closedir $dh; + +# Rename temporary file +move 'out/index.html.tmp' => 'out/index.html'; diff --git a/run/benchmark b/run/benchmark new file mode 100644 index 0000000..4c20e0e --- /dev/null +++ b/run/benchmark @@ -0,0 +1,20 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +my @cmd = ( + q{date}, + q{perl5.32.0 -le 'print "Hello world!"'}, + q{python3.7 -c 'print("Hello world!")'}, + q{ruby26 -e 'puts "Hello world!"'}, +); +my @res; +for (1..3) { + @res = (); + for (reverse @cmd) { + (my $q = $_) =~ s/'/'"'"'/g; + push @res, "\$ time $_\n" . `bash -c 'time $q' 2>&1`; + } +} +print join("\n", reverse @res); diff --git a/run/blogs b/run/blogs new file mode 120000 index 0000000..81cf1df --- /dev/null +++ b/run/blogs @@ -0,0 +1 @@ +rss \ No newline at end of file diff --git a/run/cpan b/run/cpan new file mode 120000 index 0000000..81cf1df --- /dev/null +++ b/run/cpan @@ -0,0 +1 @@ +rss \ No newline at end of file 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,@[^.]*\.,@hidden.,; + print < +
+Date: $d{$_} +
From: $f{$_} +
+Subject: $s{$_} +

+HTML +} + +$nntp->quit; diff --git a/run/reddit b/run/reddit new file mode 120000 index 0000000..81cf1df --- /dev/null +++ b/run/reddit @@ -0,0 +1 @@ +rss \ No newline at end of file diff --git a/run/rss b/run/rss new file mode 100644 index 0000000..2dfb60f --- /dev/null +++ b/run/rss @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use HTML::Entities; +use XML::Feed; +use Encode qw(decode encode); + +my %feeds = ( + blogs => 'http://blogs.perl.org/atom.xml', + reddit => 'https://www.reddit.com/r/perl/.rss', + cpan => 'https://metacpan.org/feed/recent', +); +(my $name = $0) =~ s,.*/,,; + +my $feed = XML::Feed->parse(URI->new($feeds{$name})) + or die XML::Feed->errstr; +my @entries = $feed->entries; + +# Print summary of five latest entries +for my $entry (@entries[0..4]) { + my $d = encode_entities $entry->issued->ymd; + my $f = encode_entities decode('utf8', $entry->author); + my $s = encode_entities decode('utf8', $entry->title); + my $l = encode_entities $entry->link; + print < +
$d
+
$f
+ + +HTML +} diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..679f9d2 --- /dev/null +++ b/src/index.html @@ -0,0 +1,73 @@ + + + + +Perl is Dead + + + + +

Perl is Dead?

+ +

+"Perl is dead" is an urban legend and conspiracy theory alleging +that famous programming language Perl, created by Larry Wall, died +on 19 July 2000 and was secretly replaced by a whitespace-sensitive +look-alike. The rumour began circulating around 2000, but grew in +popularity after being reported on American news site Slashdot in +2005. Proponents based the theory on perceived clues found in Wall +speeches and Perl book covers. Clue-hunting proved infectious, and +within a few weeks had become an international phenomenon. +(paraphrased from Wikipedia…) + +

+
+.run benchmark
+
+
+ +

+Jokes aside, Perl is not dead. +It is still an excellent choice for a host of applications. +It still has – by far – the fastest startup time among +all its competitors, as you can see in the figure to the right. +Every millisecond counts if you're building a command-line utility. + +

+Furthermore, the language and its community continues to evolve +into the 2020s. Below is a summary of the recent activity of various +Perl forums as of +.eval print scalar localtime, ".\n"; + +

+

Latest messages on the perl5-porters mailing list

+.run p5p +
+ +
+

Latest articles on blogs.perl.org

+.run blogs +
+ +
+

Latest posts on the /r/perl subreddit

+.run reddit +
+ +
+

Latest messages on the #perl IRC channel

+.run irc +
+ +
+

Latest nodes on PerlMonks

+.run perlmonks +
+ +
+

Latest uploads to CPAN

+.run cpan +
+ + + diff --git a/src/style.css b/src/style.css new file mode 100644 index 0000000..f02e3f0 --- /dev/null +++ b/src/style.css @@ -0,0 +1,40 @@ +body { + font: 16px/1.4 Arial, Helvetica, sans-serif; + width: 600px; + margin: 0 auto; + padding: 0 1em; +} + +h1, h2, h3, h4, h5, h6 { + font-family: "Times New Roman", Times, serif; +} + +pre, code, tt { + font-size: 14px; +} + +h1#title { + text-align: center; +} + +p.intro { + font-size: 18px; + color: #d00; + margin: 0 1.8em; + text-align: justify; +} +p.intro cite { + font-size: 14px; + color: black; + opacity: 0.8; + font-style: normal; +} + +.box { + border: 1px dashed #ccc; + padding: 0 1em; + margin: 1em 0; +} +.box h2 { + font-size: 18px; +} -- cgit v1.2.3