#!/usr/bin/perl use strict; use warnings; use feature 'say'; use Mojo::File qw(path); use Mojo::JSON qw(decode_json); # Path to your JSON file my $file = path('yay_sports.json'); # Slurp and decode JSON my $json = decode_json( $file->slurp ); # Loop through each match for my $match ( @{$json->{response}} ){ # match status my $status = $match->{fixture}{status}{long}; # team names my $home = $match->{teams}{home}{name}; my $away = $match->{teams}{away}{name}; # half time my $ht_home = $match->{score}{halftime}{home} // 'N/A'; my $ht_away = $match->{score}{halftime}{away} // 'N/A'; # full time my $ft_home = $match->{score}{fulltime}{home} // 'N/A'; my $ft_away = $match->{score}{fulltime}{away} // 'N/A'; # output, may want to consider not printing if things haven't # happend yet, where FT shows N/A for example say "Match: $home vs $away"; say "Status: $status"; say "Halftime Score: $home $ht_home - $ht_away $away"; say "Fulltime Score: $home $ft_home - $ft_away $away"; say "-" x 40; }