Hi, I'm calling an API internally from a script and need to grep few values from the output of API,when the call is being made to an API,it could take some amount of time to get the output,but my code was trying to grep values from the output file before the output is generated.Is there any way to do further processing only after output is generated?

while ( @accumRow = $getAccums->fetchrow_array() ) { push(@accums,@accumRow); ($currAccumId) = @accumRow; print ("currAccumId = @accumRow \n"); $getSbscrpidFrmAccum->bind_param(1,$currAcct); $getSbscrpidFrmAccum->bind_param(2,$currAccumId); $getSbscrpidFrmAccum->execute()|| logDBIError(" execut +e failed for fetching sbscrpId from Accum of the Account $currAcct + "); while (@sbscrpRow = $getSbscrpidFrmAccum->fetchrow_arr +ay() ) { ( $sbscrp_id ) = @sbscrpRow; } $xmlFile = "GetUsgSummary_" . $currAcct ."_".$currAccu +mId.".xml"; createXmlForUpd( $xmlFile, $currAcct,$sbscrp_id ); $retValue = invokeServer( $currAcct , $xmlFile,$currAc +cumId ); if ( $retValue == ERROR ) { logMessage( "API call failed for acct $currAcct wi +th accumId @accumRow of subscriber $sbscrp_id \n"); } else { open(FILE,"<","$retValue"); my $accumId = 0; my @inclUnits = (); my ($inclUnits); my ($inclUnitsUsed); my ($shared); while(<FILE>) { if($_ =~ m/accumId="$currAccumId"/) { @inclUnits = split(/ /,$_); ($inclUnits) = grep(/inclUnits=/, @inclUni +ts); $inclUnits =~ s/inclUnits="([^"]+)"/$1/g; ($inclUnitsUsed) = grep(/inclUnitsUsed=/, +@inclUnits); $inclUnitsUsed =~ s/inclUnitsUsed="([^"]+) +"/$1/g; ($shared) = grep(/shared=/, @inclUnits); $shared =~ s/shared="([^"]+)"/$1/g; logMessage( "accumId=$currAccumId : $inclU +nits : $inclUnitsUsed : $shared\n"); } } close(FILE); } }

In reply to Wait for the response of API by rkrish

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.