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.


In reply to (Ovid - design your programs) Re(3): hash/array by Ovid
in thread hash/array by malaga

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.