this is my code below, am getting the results very well, my problem is parsing them, i tried this -> coz of an array but still cant parse out the message
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request;
use JSON;
my $url = 'link';
my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 }, );
$ua->agent("MyApp/0.1");
my $req = HTTP::Request->new(GET => $url);
my $response = $ua->request($req);
my $parse_json = JSON::XS->new->decode ($response->content);
if ($response->is_success) {
for my $match (@{$parse_json->{leagues}}) {
my $elapsed = $match->{events}->{competitions}->{status}{display
+Clock};
my $status = $match->{events}->{competitions}->{wasSuspended};
my $home = $match->{events}->{competitors}->{team};
my $away = $match->{events}->{competitors}->{team};
my $away_goal = $match->{events}->{competitions}->{competitors}->
+{score};
my $home_goal = $match->{events}->{competitions}->{competitors}->
+{score};
print "$elapsed: $home: $home_goal: Suspended Match: $status";
print "$elapsed: $away: $away_goal: Suspended Match: $status";
}
} else {
print $response->decoded_content;
print $response->status_line, "n";
}
|