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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|