malaga wrote:
...but i've changed it so many times...
With all due respect, this implies that you probably started coding your program without designing it first. Let's try a bit of pseudo-code mixed with step-wise refinement. Here's what you said you needed:
open a text file that has rows and colums (tab delimited), look for a name (in the first column), get the row that has the name so i can do stuff to it.
Break that into separate lines and you have pseudo-code!
open a text file (tab delimited)
look for a name in the first column
get the row that has the name so i can do stuff to it.
That pretty much covers the task. Further refinement gets this:
open a text file
while I read a line from the file
look for a name in the first column
if the name is what I want, do stuff to the row
end while
Even more refinement:
# still pseudo-code here
open inputFile or die
while ( read line from inputFile ) {
get first item from tab-delimited line
if ( first item equals "something I need" ) {
do something important
}
}
close file
That's a pretty simple example. However, larger programs can be tackled in a similar fashion (though I use Warnier-Orr). There's probably nothing in the above pseudo-code that you can't figure out. By breaking it down that way, it's much easier to conceptualize and follow the logic.
In fact, if you do have a problem with the above pseudo-code, I suspect that it's in the following line: "get first item from tab-delimited line". Now, rather than having a vague problem that you don't know how to approach (second quote above), you have a very specific task that is much easier to deal with.
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats. |