Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (31 sloc) 1014 Bytes
#!/usr/bin/env perl
use v5.28;
use strict;
use warnings;
Task: Write a script to use BC Gov News API.
This script prints out the top and feature post headlines.
Example output:
$ perl
* News Release: Third urgent and primary care centre opens in Greater Vancouver
* Backgrounder: North Vancouver UPCC
* News Release: Province seeks feedback to ban, reduce, recycle more plastics
use HTTP::API::Client;
my $agent = HTTP::API::Client->new(
base_url => URI->new(''),
pre_defined_data => { 'api-version' => '1.0' },
my $homeInfo = $agent->json_response();
foreach my $key (qw( topPostKey featurePostKey )) {
my $postInfo = $agent->json_response();
say $key;
foreach my $document ( $postInfo->{documents}->@* ) {
say "* $document->{pageTitle}: $document->{headline}";
say '';
You can’t perform that action at this time.