Rosetta Code/Find unimplemented tasks: Difference between revisions

→‎{{header|Perl}}: rehabilitated task
(→‎{{header|Perl}}: rehabilitated task)
Line 1,424:
 
=={{header|Perl}}==
<lang perl>use LWP::UserAgent;
Using JSON (not parsed, just Regex.)
 
<langmy perl>use$ua = LWP::Simple 'get'UserAgent->new;
$ua->agent('');
 
sub enc { join '', map {sprintf '%%%02x', ord} split //, shift }
my $fmt = 'http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:%s&cmlimit=500&format=json';
sub get { $ua->request( HTTP::Request->new( GET => shift))->content }
my $lang = shift
or die "No language given.\n";
 
sub urlencodetasks {
{ my ($category) = urlencode shift;
{join '', map {sprintf '%%%02x', ord} split //, shift}
my $fmt = 'http://www.rosettacode.org/mw/api.php?' .
sub tasks
my $fmt = 'http://www.rosettacode.org/w/api.php?action=query&listgenerator=categorymembers&cmtitlegcmtitle=Category:%s&cmlimitgcmlimit=500&format=json&rawcontinue=';
{my $category = urlencode shift;
my @tasks;
my $json = get (sprintf $fmt, $category);
forwhile (;;1) {
{ push @tasks, $json =~ /"title":"(.+?)"\}/g;
$json =~ /"cmcontinuegcmcontinue":"(.+?)"\}/ or last;
$json = get (sprintf $fmt . '&cmcontinuegcmcontinue=%s', $category, enc $1);
}
$category, urlencode $1;}
return @tasks;}
}
 
my @all%language = map {$_, 1} tasks shift || 'Programming_Tasksperl';
$language{$_} or print "$_\n" foreach tasks('Programming_Tasks'), tasks('Draft_Programming_Tasks');</lang>
my %lang = map {$_, 1} tasks $lang
or die "No such category.\n";
$lang{$_} or print "$_\n"
foreach @all;</lang>
 
'''See also:''' [[User:ImplSearchBot/Code]]
2,392

edits