I have a complicated problem to even explain, but I have posted a sample of the code to make my question clear or at least I am trying to.
All that I am trying to do is after I get a result back from a DB, I am storing this variable into an array:
push @array,$N_NUM;
And after sending this array to a sub routine. The sub will get all the values in this array and run another query to a DB, and for each value found it should return a FOUND or NOT FOUND back inside the same while loop where the push array was, because the rest of the code prints a lot of stuff to the browser. And doing it like in my code sample isn't working at all.
Would be very nice if I could get some feed back on it,
Thank you all!
Here is the sample code for my problem:
#More code is here, this is just to explain my problem...
$sth->execute() || die $sth->errstr;
while (my $pointer = $sth->fetchrow_hashref){
$N_NUM = &cleaner ($pointer->{'number'});
push @array,$N_NUM;
&total(@array);
#Print HTML
print "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpaddin
+g=\"0\">
<tr>
<td width=\"15\"> </td>
<td class=\"textgreyb\">Products</td>";
# My problem is here cause I can only get the value of this varialbe $
+results when I have send the array @array to the SUB TOTAL
+
&total;
print " <td class=\"textgreyb\">$results</td>
</tr>";
} End while
sub total
{
my $all_info = shift (@_); # gets values passed by @array, it has all
+the Numbers found on DB
my @info = split/ /,"$all_info";
# It checks a DB table and if the number is found here it should send
+back a value of "FOUND" or "NOT FOUND"
code would go here getting the values in here is not a problem...
ok, let say that my final result is;
my $results="FOUND";
return;
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.