You have understood the phrase perfectly: it is another way of saying "If you had asked..."
(My personal opinion is that it is a pointlessly pompous way of saying it; but I didn't get a vote.)
The base idiom is BE to VERB, where BE is the appropriate form of the verb be and VERB is the infinitive form of any verb. It means, approximately, "suppose", in both the senses in which that quirky word is used.
Thus, in the indicative (real) mode it means be supposed or expected to do whatever VERB names. For instance, I am to go to London tomorrow means "I am supposed to go" or "I am expected to go to London tomorrow".
In the irrealis mode, expressed with the past form, it takes the other meaning of suppose, "assume as a hypothesis". If I were to go to London (or, alternatively, Were I to go to London) means "Let us suppose that I go to London" or "If we assume that I go to London".
In your example, the author asks you to "suppose" not something which happened in the present, which would be expressed as "If you were to ask world leaders today", but something which happened in the past, a few hundred years ago. You have to 'backshift' the expression from present to past.
But you can't do that in the ordinary way, by using the ordinary past form of BE, were—because you've already used up that form in the present. The workaround in English for expressing a past irrealis is to employ the appropriate form of HAVE + the past participle of VERB: "If you were to have asked world leaders a few hundred years ago".
Notice that the same workaround is employed in the ordinary, non-pompous way of expressing the same thought: "If you asked world leaders today" is backshifted as "If you had asked world leaders a few hundred years ago".
This looks like a perfect construction, but it's not; it's the past irrealis construction.
Your second sentence is a correct third conditional form as these forms are taught to English language learners.
Your first sentence has a difference in nuance that is not necessarily grammatically incorrect but doesn't conform to how the forms are taught. While the result (having gotten the flu) is in the past and can't be changed, there's an implication that you could still change your habits and start eating more fruit, and that if you do, you could possibly avoid repeating the result and getting the flu again.
Best Answer
Consider the difference:
The backshift to past-tense with asked and to past-perfect with had asked occurs to reflect the hypothetical conditionality of the statements in the respective main clause.