#!/usr/bin/perl -wT use strict; use warnings; use LWP::UserAgent; use HTTP::Request; use JSON; use DBI; my $host = ""; my $usr = ""; my $pwd = ""; my $dbname = ""; my $dbh = DBI->connect("DBI:mysql:$dbname:$host", $usr, $pwd, { AutoCommit => 1, RaiseError => 1, }) or die $DBI::errstr; my $url = "https://v3.football.api-sports.io/fixtures?live=1"; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(GET => $url); $req->header('x-rapidapi-host' => 'v3.football.api-sports.io'); $req->header('x-rapidapi-key' => 'e73299760f882d'); my $response = $ua->request($req); my $parse_json = JSON::XS->new->decode ($response->content); if ($response->is_success) { for my $match (@{$parse_json->{response}}) { my $elapsed = $match->{fixture}{status}{elapsed}; my $status = $match->{fixture}{status}{short}; my $home = $match->{teams}{home}{name}; my $away = $match->{teams}{away}{name}; my $ht_home = $match->{score}{halftime}{home} // 'N/A'; my $ht_away = $match->{score}{halftime}{away} // 'N/A'; my $ft_home = $match->{score}{fulltime}{home} // 'N/A'; my $ft_away = $match->{score}{fulltime}{away} // 'N/A'; my $query = $dbh->prepare("# MYSQL QUERY"); $query->execute(); my $query_data = $query->fetchrow_array; $query->finish; # more select below............. if (int($elapsed > 0)) { my $Create = $dbh->prepare("# MYSQL QUERY) VALUES()"); $Create->execute(); $Create->finish(); } # more insert below............. } } else { print $response->status_line; } $dbh->commit; $dbh->disconnect;