#!/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; } #### Match: Sortland vs B�rum Status: First Half Halftime Score: Sortland 0 - 0 B�rum Fulltime Score: Sortland N/A - N/A B�rum ---------------------------------------- Match: Gal�cia U20 vs Jacuipense U20 Status: Halftime Halftime Score: Gal�cia U20 1 - 2 Jacuipense U20 Fulltime Score: Gal�cia U20 N/A - N/A Jacuipense U20 ----------------------------------------