in reply to How to search a Name from a file and extracts its designation

You're not thinking (or expressing yourself) carefully enough to get thoughtful answers. You'll get a few good guesses maybe, but correct solutions, probably not (unless someone gets lucky). Here are the unanswered questions we would need to help you with a correct solution:

Each of the solutions you've been provided fail to deal with compound names and name clashes. Neither of them scale particularly well either. But they're both just fine for your limited sample input. This illustrates the point that brief sample input that doesn't show the breadth of possible input, combined with an incomplete description of the problem can lead to answers that seem fine, but will fail in real use.

If this is a school assignment, go back to the professor and get answers to these questions so that you can more carefully craft a correct solution. If it's a work project, then you should know enough about your client to be able to answer these questions. If you don't, you need to nail down the spec with your client better.

Only then can you begin to produce a useful solution. And until the details are known that can lead to a useful solution, there's no point in anyone wasting time giving you solutions based on guess work or incomplete specifications, because they will miss some detail that is crucial to the client or to your professor.


Dave

  • Comment on Re: How to search a Name from a file and extracts its designation