...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!
That pretty much covers the task. Further refinement gets this: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.
Even more refinement: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
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.# 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
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.
In reply to (Ovid - design your programs) Re(3): hash/array
by Ovid
in thread hash/array
by malaga
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |