The past perfect is formed with had (past of have) + the past participle. It allows us to express an action which occurred before another action, both actions having occurred in the past. It is used to differentiate the order in which past actions occurred:
When he had finished his trip around the world, Bruno started the San Francisco-based Delavigne Corporation. Bruno started the San Francisco-based Delavigne Corporation after his world trip (both actions happened in the past).
I had finished my work before my parents went to bed. First I finished my work, then my parents went to bed.
The past perfect can also be used in its progressive form (had been doing sthg) to express an unfinished action at a specific moment of time in the past:
Before his car accident, Bruno had been working hard on creating new perfumes.
I had been studying surgery for ten years when I decided to become a clown.
Until 1990, the president had been working in the dairy industry.