Skip to content

Instantly share code, notes, and snippets.

@JRaspass
Created June 14, 2019 08:36
Show Gist options
  • Select an option

  • Save JRaspass/293df8e791cef4774ee107689c3e5e22 to your computer and use it in GitHub Desktop.

Select an option

Save JRaspass/293df8e791cef4774ee107689c3e5e22 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl6
use Cro::HTTP::Client;
my @langs = (
'Julia',
'https://julialang.org/downloads/',
/"stable release: v"(.+?)"<"/,
'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+)"."/,
);
my $len = @langs[0, 3 … *]».chars.max;
for @langs -> $lang, $url, $re {
state $client = Cro::HTTP::Client.new(:!follow :http<1.1>);
my $res = await $client.get($url);
printf "%*s %s\n", $len, $lang, (await $res.body) ~~ $re ?? ~$0 !! Nil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment