forked from code-golf/code-golf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatest-langs
executable file
·47 lines (34 loc) · 1 KB
/
latest-langs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env perl6
use Cro::HTTP::Client;
constant @langs = (
'Haskell',
'https://www.haskell.org/ghc/download.html',
/"download_ghc".+?">"(.+?)"<"/,
'Julia',
'https://julialang.org/downloads/',
/"stable release: v"(.+?)"<"/,
'Lua',
'https://www.lua.org',
/"versions.html".+?">Lua "(.+?)"<"/,
'Nim',
'https://nim-lang.org',
/"Version "(\S+)" released"/,
'Perl',
'https://www.perl.org',
/'"version-highlight">'(.+?)"<"/,
'PHP',
'https://www.php.net/downloads.php',
/"Stable</span>"\s*"PHP "(\S+)/,
'Python',
'https://www.python.org',
/"Latest: <".+?">Python "(.+?)"<"/,
'Ruby',
'https://www.ruby-lang.org/en/downloads/',
/"stable version is "(\S+)"."/,
);
constant $len = @langs[0, 3 … *]».chars.max;
constant $client = Cro::HTTP::Client.new(:!follow :http<1.1>);
for @langs -> $lang, $url, $re {
my $res = await $client.get($url);
printf " %*s %s\n", $len, $lang, (await $res.body) ~~ $re ?? ~$0 !! Nil;
}