nasa has asked for the wisdom of the Perl Monks concerning the following question:
Great this returns $record which will print out the number corresponding on the right. Now the difficult part. I now need to search the left side for that number and be given again the corresponding number on the right. I have tried the same search for the variable $record thus.$data_file="reff.data"; open(DAT, $data_file) || die("Could not open file!"); @raw_data=<DAT>; @results = grep( /^$line[3]/, @raw_data); foreach( @results ) { $record = $_; # strip the beginning key $record =~ s/^\d+//; print "$record"; } close(I);
But that printed out the whole database I can inject a number from the left and be given the Corresponding right. But then I need the script to go on and find that corresponding number in the left, and give again the corresponding right and so on and so on. I am not a module man but I have tried many things Some with surprising results However after being bogged down with this problem For about three months now, I really need to get past this and Soldier on . God bless Ye All…Nasa.$data_file="reff.data"; open(DAT, $data_file) || die("Could not open file!"); @raw_data=<DAT>; @results = grep( /^$record/, @raw_data); foreach( @results ) { $record2 = $_; # strip the beginning key $record2 =~ s/^\d+//; print "$record2"; } close(I);
edited: Sat Feb 15 20:53:30 2003 by jeffa - title change (was: Bewildered.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with (recursively?) searching flat file database
by Joost (Canon) on Feb 14, 2003 at 16:32 UTC | |
|
Re: Problem with (recursively?) searching flat file database
by jasonk (Parson) on Feb 14, 2003 at 16:21 UTC | |
|
Re: Problem with (recursively?) searching flat file database
by dws (Chancellor) on Feb 14, 2003 at 19:18 UTC |