Hello, everyone. One of my grammar books says both past perfect and simple past tense mean the same thing in the following example:

When the teacher had arrived, they stopped talking.=When the teacher arrived, they stopped talking.

But my another book says they don't mean the same thing. It gives two examples:

When he closed the door, I began to scream. The book says it means "I screamed before the door was completely closed."

When he had closed the door, I began to scream. The book says it means "I screamed after the door was completely closed."

(Both books are not written by native speakers)

May I ask which opinion of the two books is true? Please help me with this, thank you!
1 2 3
Comments  (Page 3) 
This is the use of the past perfect. You use the past perfect when you have two events that happened in the past and you want to put them together in one sentence. The event that happened firts is spoken in past perfect which means you have to use the auxilary "had + verb in past participle" and the event that happened second is spoken in simple past. The most common connectors are: before, after, when and by the time. The first thing that you have to decide is in which order the events happened. There are many ways to write the sentence that depends on what connector you are using.
e.g. This happended first: all the passangers got out of the plane.
This happened after: the plane exploded.

All the passangers had gotten out of the plane when / before / by the time the plane exploded. or
Before / by the time / when the plane explded, all the passangers had already gotten out of the plane. (already is only for emphasis) or
The plane exploded after the passengers had gotten out of the plane.

Using the past perfect simple (had + verb in past participle)
means that the event that happened first stopped before or long before the second one started.

Using the past perfect continuous or progressive (had + been + verb in gerund ing) means that the first event stopped at the same time the second started.
e.g. I had been driving my new car for only 3 months when my brother crashed it.

I hope this info is helpful.