We don't bite newbies here... much | |
PerlMonks |
Re: Extra iteration while fetching 'fetchrow_array' in DBI and standerd way of using DBIby roboticus (Chancellor) |
on Jun 15, 2007 at 12:51 UTC ( [id://621456]=note: print w/replies, xml ) | Need Help?? |
cool: No offense intended, but you should trim down your code before sending a question like that. Many will skip the node if they have to work too hard to see the problem. (See nodes like How (Not) To Ask A Question). Anyway, on to your question. Based on your statement and the code, I'd imagine that your problem is that you process the data this way:
The $sth2->fetchrow_array() call returns false when it has nothing to report back, and you're assigning that to an array. Move the extra assignment into your loop so it's only copied if you have a row of data:
But you really need to start working on structuring your programs to make them simpler to read. This will help make your code more maintainable, as well as making it easier to steal bits from for other projects. Use indentation liberally, don't be afraid of blank lines, and use meaningful variable names. I'm not going to take on your entire script, but let's work on this loop for a moment. A little bit of rearranging will make it a little easier to read:
Now I may have overformatted it, but it certainly makes it easier to see what you're doing.
In Section
Seekers of Perl Wisdom
|
|