I can see you people are trying to help me.
In the past I have confused you with nonworking code examples.
I will try to explain the problem with as little code included as possible.
I have a flat text file database called reff.data.
The database consists of two columns of ten digit numbers.
Son numbers Fathering numbers
1045316394 1045316144
1045316407 1045316394
1045316419 1045316407
1045316438 1045316419
1045316469 1045316394
1045316492 1045316407
1045316505 1045316492

The left column is the son of the right column in that all numbers in the
Left column were bought into the database by a number in the right column.
Note that in this database left numbers can never be the same but right numbers can.

As with children must be individuals but can have the same father,
I want to know which number fathered 1045316419 so I ask.

$data_file="reff.data"; open(DAT, $data_file) || die("Could not open file!"); @raw_data=<DAT>; @results2 = grep( /1045316419/, @rawdata); foreach( @results ) { $record = $_; # strip the beginning key $record =~ s/^\d+//; print "$record"; } close(I);

When I send this to the browser it will print out 1045316407 because that is indeed the
Corresponding number.
It will print 1045316407 because that is what $record represents.
Now I need to step back again and ask what number fathered that number (1045316407). But I don’t really have the number in my hand I have it as $record.
If I use the same script and ask perl to do the same search for $record and give me the corresponding number
It will return exactly the same result ( no good).
I need to step back several times, asking for the number that fathered the number before it
but I only have one number to start with.
Nasa.


In reply to Correction to Database problem by nasa

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.