Rosetta Code/Find unimplemented tasks: Difference between revisions

Content added Content deleted
(→‎{{header|Perl}}: rehabilitated task)
Line 1,424: Line 1,424:


=={{header|Perl}}==
=={{header|Perl}}==
<lang perl>use LWP::UserAgent;
Using JSON (not parsed, just Regex.)


<lang perl>use LWP::Simple 'get';
my $ua = LWP::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 urlencode
sub tasks {
my($category) = shift;
{join '', map {sprintf '%%%02x', ord} split //, shift}
my $fmt = 'http://www.rosettacode.org/mw/api.php?' .
sub tasks
'action=query&generator=categorymembers&gcmtitle=Category:%s&gcmlimit=500&format=json&rawcontinue=';
{my $category = urlencode shift;
my @tasks;
my @tasks;
my $json = get sprintf $fmt, $category;
my $json = get(sprintf $fmt, $category);
for (;;)
while (1) {
{push @tasks, $json =~ /"title":"(.+?)"}/g;
push @tasks, $json =~ /"title":"(.+?)"\}/g;
$json =~ /"cmcontinue":"(.+?)"}/ or last;
$json =~ /"gcmcontinue":"(.+?)"\}/ or last;
$json = get sprintf $fmt . '&cmcontinue=%s',
$json = get(sprintf $fmt . '&gcmcontinue=%s', $category, enc $1);
}
$category, urlencode $1;}
return @tasks;}
@tasks;
}


my @all = tasks 'Programming_Tasks';
my %language = map {$_, 1} tasks shift || 'perl';
$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]]
'''See also:''' [[User:ImplSearchBot/Code]]