Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Rainforest QA challenge
use strict;
use warnings;
use Data::Dumper;
use English qw(-no_match_vars);
use JSON qw(decode_json);
use LWP::UserAgent;
# basically follow the url chain until you reach the end
# start url:
my $base_url = "";
my $current_url = "";
my $ua = LWP::UserAgent->new( agent => 'RainforestQAChallenge/Perl libperl');
while ( 1 ) {
my $json_response;
eval {
my $response = $ua->get($current_url);
$json_response = decode_json($response->decoded_content || '');
my $id;
if ($json_response->{follow}) {
($id) = $json_response->{follow} =~ /id=(\d+)$/;
else { # at the end
print Dumper $json_response->{message};
$current_url = "$base_url$id";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.