nasa has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Database problem.
by pfaut (Priest) on Feb 15, 2003 at 14:55 UTC | |
Re: Correction to Database problem
by tachyon (Chancellor) on Feb 15, 2003 at 15:41 UTC | |
Re: Correction to Database problem
by demerphq (Chancellor) on Feb 15, 2003 at 22:50 UTC | |
Re: Correction to Database problem
by jasonk (Parson) on Feb 15, 2003 at 15:25 UTC | |
Re: Database problem.
by zengargoyle (Deacon) on Feb 15, 2003 at 15:17 UTC | |
Re: Correction to Database problem
by toma (Vicar) on Feb 15, 2003 at 23:16 UTC | |
Re: Correction to Database problem
by ilcylic (Scribe) on Feb 16, 2003 at 01:13 UTC | |
by pfaut (Priest) on Feb 16, 2003 at 01:16 UTC |