I have a sample data, my question is that what is the best way to run multi-task, the URL API Endpoint is the one which is different but the tasks are the same like

my $url = "https://v3.football.api-sports.io/fixtures?live=1"; my $url = "https://v3.football.api-sports.io/fixtures?live=2"; my $url = "https://v3.football.api-sports.io/fixtures?live=3";

i was thinking on that this could work after code block i put continue Loop then other code block

my problem is that i don't want to make multiple files which does same work, i want to include them in same file and run once

#!/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;

In reply to Running multi task by joyfedl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.