CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
While loop confusion

 



arun10427
Novice

Feb 7, 2010, 10:44 AM

Post #1 of 2 (582 views)
While loop confusion Can't Post

Hi
I am accessing a dbf file with lots of records. This is the portion of code where I am having confusion about!
CODE

while ($i<=$rdb->last_record)
{
my @data = $rdb->get_record($i,"X", "Y"
if($data[2]<20)
{
$comment = "Good";
wdb->set_record($i,$data[1],$data[2],$comment);
}
if($data[2]>20)
{
#PLEASE HELP ME FILL THIS PART
}
This is what I have to do

--> If value of Y is less than 20
-> Write comments as good
-->If value of Y is 20 or greater
->Keep looking until X value is greater than 5
->Count number of records until X value 5 is reached--(*)
->If number of these consecutive records counted in (*) is greater than 10
-->write bad_not_fixed to comments
->If number of consecutive records counted in (*) is 10 or less
--> write fixed to comments
The main reason for my confusion is how do you first finish counting the records(10) and then go back and write? Please help me with this.
I wold really appreciate it.
Cheerz


arun10427
Novice

Feb 7, 2010, 4:25 PM

Post #2 of 2 (574 views)
Re: [arun10427] While loop confusion [In reply to] Can't Post

Basically,

if i have 50 records, with X,Y and comments column(comments is empty column at start). My motive is based on the values of X and Y column I have to populate comments column.

If value of X is greater than 20
then I traverse the Y records till the value of Y reaches 5, If the number of Y records I had to traverse is greater than 10,I write
bad_not_fixed to the comments column corresponding to Y records traversed upto 5. If the number of Y records is less, I write fixed to comments for the Y records counted.


In short, count records till Y reaches value of 5, If counted records>10 "comments = bad_not_fixed " else "fixed"

Sorry about posting it again.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives