Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^3: continuously query

by NetWallah (Canon)
on Dec 22, 2020 at 03:54 UTC ( [id://11125598]=note: print w/replies, xml ) Need Help??


in reply to Re^2: continuously query
in thread continuously query

There are a few issues with your post:
  • It would help if you provide SHORT, RUNNBLE CODE that demonstrates the issue
  • It would help if code were indented properly - that would allow others to see loop boundaries
  • You have misunderstood how to process the return value from fetchall_arrayref
  • You have a syntax error in "while ( $status eq 'PAID') ) {"
  • Your "redo" will not work the way you seem to expect
Please try to understand and use standard perl "idioms" - they help make code more understandable and avoid bugs.

Here is an idiomatic flow for your case:

my $query = $dbh->prepare("SELECT ordernumber FROM orders ORDER BY cre +ated ASC"); $query->execute(); ####### FUNCATION (A) while( my $row = $query->fetchrow_arrayref() ) { my $ordernumber = $row->[0]; # First, and only field in returned +list # WHEN I PRINT THE OUTPUT IS # 545455 # 745454 # 645450 # NOW I WANT TO CHECK EACH ORDER NUMBER VIA LINK # ITS LIKE I WANT TO RUN HTTP REQUEST FOR EACH ORDER NUMBER my $url = "LINK/$ordernumber"; print "URL: $url\n"; my $req = HTTP::Request->new(GET=>$url); my $resp = $ua->request($req); my $response = JSON::XS->new->decode ($resp->content); my $status = $response->{status}; # WHILE WE GET ORDER NUMBER WITH MATCHING RESLUTS while ( $status eq 'PAID') { #// DO STAFFS HERE #// WHEN DONE THEN KEEP CHECKING OTHER ORDER NUMBER USING REDO } #no redo; # REDO FUNCATION (A) AFTER SUCCESS - ITS LIKE RESTART T +HE WHOLE FUNCATION AGAIN # BEACUSE AFTER SUCCESS, I HAVE TO KEEP ALSO CHECKING REAMI +NING ORDER NUMBER STATUES } $dbh->disconnect();

                "Imaginary friends are a sign of a mental disorder if they cause distress, including antisocial behavior. Religion frequently meets that description"

Replies are listed 'Best First'.
Re^4: continuously query
by bigup401 (Pilgrim) on Dec 22, 2020 at 07:06 UTC

    thank you

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11125598]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-25 22:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found